OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
analyse_error.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "analyse_define.h"
#include "analyse_getall.h"
#include "analyse_print.h"
#include "analyse_memory.h"
#include "analyse_comment.h"
#include "analyse_read_tools.h"
#include "analyse_error.h"

Go to the source code of this file.

Functions

static int compar_error (const void *error_1_p, const void *error_2_p)
static analyse_error_info_terror_create (int size)
void analyse_error_cnt (analyse_error_info_t *error_list, int id)
void analyse_error_set_tmp_cnt (analyse_error_info_t *error_list, int id, int value)
void analyse_error_get_cnt (analyse_error_info_t *error_list, int id, int *global_cnt, int *tmp_cnt)
void analyse_error_return_message (analyse_error_info_t *error_list, int error_warning_type, int language, int id, char **title, char **description, char **comment)
void analyse_error_file_read (analyse_error_info_t **error_p, char *infilename)

Variables

static int ANALYSE_NB_ERROR =0

Function Documentation

◆ analyse_error_cnt()

void analyse_error_cnt ( analyse_error_info_t * error_list,
int id )

Definition at line 73 of file analyse_error.c.

74{
75 analyse_error_info_t tmp_error;
76 analyse_error_info_t *work_error=NULL;
77
78 /* Search Error */
79 tmp_error.id = id;
80 work_error = bsearch( &tmp_error, error_list, ANALYSE_NB_ERROR, sizeof(analyse_error_info_t), compar_error);
81
82 if (work_error != NULL)
83 {
84 work_error->global_cnt++;
85 work_error->tmp_cnt++;
86 }
87}
static int ANALYSE_NB_ERROR
static int compar_error(const void *error_1_p, const void *error_2_p)
struct analyse_error_info_s analyse_error_info_t
initmumps id

◆ analyse_error_file_read()

void analyse_error_file_read ( analyse_error_info_t ** error_p,
char * infilename )

Definition at line 209 of file analyse_error.c.

210{
211/* ls41k10 */
212 FILE *infile=NULL;
213
214 char line[ANALYSE_SIZE_OF_LINE];
215 char key[ANALYSE_SIZE_OF_LINE];
216 int id;
217 int linecount = 0;
218
219 analyse_comment_t *comment;
220 analyse_error_info_t *work_error;
221 analyse_error_info_t tmp_error;
222
223 int new_count = 0;
224 int already_print = 0;
225
226 int cnt, size;
227 int *tab;
228
229
230 /*************/
231 /* Open File */
232 /*************/
233/* ls41k10+++ */
234 /* security, in case fopen crashes with error_filename = NULL */
235 if (infilename != NULL)
236 {
237 infile = fopen(infilename,"r");
238 }
239/* ls41k10 --- */
240
241 if (infile == NULL)
242 {
243 /*
244 Analyse_Print_Error_Level("*** Analyse Read Error : Unable to read Error Definition File :\n", 2);
245 Analyse_Print_Error(infilename);
246 return;
247 */
248
249 Analyse_Print_Debug(" \nNo Error File Found. Use Default\n");
250
251
252 return;
253 }
254
255
256 /***************************/
257 /* Allocate Message Memory */
258 /***************************/
259
260 /* Count message */
261 analyse_count_error(line, infile, infilename, &linecount, &cnt);
262 rewind(infile);
263 analyse_stack_error(line, infile, infilename, &linecount, &cnt, &size, &tab);
264
265 ANALYSE_NB_ERROR = cnt;
266 analyse_free(tab);
267
268 *error_p = error_create(ANALYSE_NB_ERROR);
269
270
271 /****************/
272 /* Read Message */
273 /****************/
274 rewind(infile);
275 while ( ( analyse_getline(line, infile, infilename, &linecount) != -1) &&
276 ( strncmp(line, "/END", 4) != 0 ))
277 {
278
279 /* ls41l33 if (strstr(line, "/ANALYSE/ERROR/") != NULL) */
280 if (strstr(line, "/ANALYSE/MESSAGE/") != NULL)
281 {
282 /* Search Error */
283 analyse_getkey(3 , line, key);
284 sscanf(key, "%d", &id );
285
286 tmp_error.id = id;
287 work_error = bsearch( &tmp_error, *error_p, ANALYSE_NB_ERROR, sizeof(analyse_error_info_t), compar_error);
288
289 if (work_error == NULL)
290 {
291 if (new_count >= ANALYSE_NB_ERROR)
292 {
293 if ( already_print == 0)
294 {
295 Analyse_Print_Error_Level("\n\n*** Analyse Internal Error (ANALYSE_NB_ERROR) : Too Many Messages \n\n", 2);
296 already_print = 1;
297 }
298 continue;
299 }
300
301 work_error = *error_p + new_count;
302 new_count++;
303
304 work_error->id = id;
305
306 /* Note : if file order is in id increase, this qsort does nothing ... */
308 tmp_error.id = id;
309 /* .. and this bsearch gives the same work_error */
310 work_error = bsearch( &tmp_error, *error_p, ANALYSE_NB_ERROR, sizeof(analyse_error_info_t), compar_error);
311
312 }
313
314 analyse_getkey(4 , line, key);
315 if ( (strncmp(key, "TITLE", 5) == 0) ||
316 (strncmp(key, "DESCRIPTION", 11) == 0) )
317 {
318 /* Read Comment */
319 comment = analyse_read_comment(line, infile, infilename, &linecount);
320
321 /* Add Comment */
322 if (strncmp(key, "TITLE", 5)== 0)
323 {
324 analyse_add_comment(ANALYSE_ERROR_TITLE, work_error, comment);
325 }
326 else if (strncmp(key, "DESCRIPTION", 11)== 0)
327 {
328 analyse_add_comment(ANALYSE_ERROR_DESCRIPTION, work_error, comment);
329 }
330 }
331 }
332 }
333
334 fclose(infile);
335}
void analyse_add_comment(int object_type, void *object, analyse_comment_t *comment)
struct analyse_comment_s analyse_comment_t
#define ANALYSE_ERROR_DESCRIPTION
#define ANALYSE_ERROR_TITLE
#define ANALYSE_SIZE_OF_LINE
static analyse_error_info_t * error_create(int size)
int analyse_getkey(int pos, char *line, char *name)
int analyse_getline(char line[], FILE *infile, char *infilename, int *linecount)
void analyse_free(void *block)
void Analyse_Print_Error_Level(char *text, int level)
void Analyse_Print_Debug(char *text)
analyse_comment_t * analyse_read_comment(char *line, FILE *infile, char *filename, int *linecount_p)
void analyse_count_error(char *line, FILE *infile, char *infilename, int *linecount_p, int *cnt_p)
void analyse_stack_error(char *line, FILE *infile, char *infilename, int *linecount_p, int *cnt_p, int *size_p, int **tab_p)
recursive subroutine qsort(a, idx, first, last)

◆ analyse_error_get_cnt()

void analyse_error_get_cnt ( analyse_error_info_t * error_list,
int id,
int * global_cnt,
int * tmp_cnt )

Definition at line 104 of file analyse_error.c.

105{
106 analyse_error_info_t tmp_error;
107 analyse_error_info_t *work_error;
108
109 /* Search Error */
110 tmp_error.id = id;
111 work_error = bsearch( &tmp_error, error_list, ANALYSE_NB_ERROR, sizeof(analyse_error_info_t), compar_error);
112
113 if (work_error != NULL)
114 {
115 if ( global_cnt != NULL)
116 {
117 *global_cnt = work_error->global_cnt;
118 }
119
120 if ( tmp_cnt != NULL)
121 {
122 *tmp_cnt = work_error->tmp_cnt;
123 }
124 }
125}

◆ analyse_error_return_message()

void analyse_error_return_message ( analyse_error_info_t * error_list,
int error_warning_type,
int language,
int id,
char ** title,
char ** description,
char ** comment )

Definition at line 128 of file analyse_error.c.

130{
131 analyse_comment_t *scan_comment;
132 analyse_error_info_t *work_error;
133 analyse_error_info_t tmp_error;
134 char line[ANALYSE_SIZE_OF_LINE];
135
136
137 /* Search Error */
138 tmp_error.id = id;
139 work_error = bsearch( &tmp_error, error_list, ANALYSE_NB_ERROR, sizeof(analyse_error_info_t), compar_error);
140
141 if (work_error == NULL)
142 {
143 sprintf(line, "Unknown Id for Error %d\nNo Message Available\n", id );
145
146 if ( title != NULL ) *title = NULL;
147 if ( description != NULL ) *description = NULL;
148 if ( comment != NULL ) *comment = NULL;
149
150 return;
151 }
152 else
153 {
154 /* Get Title */
155 if ( title != NULL )
156 {
157 if (work_error->title== NULL)
158 {
159 *title = NULL;
160 }
161 else
162 {
163 scan_comment = analyse_get_right_comment(work_error->title,language,ANALYSE_ENGLISH);
164 #ifdef _WIN64
165 *title = _strdup(scan_comment->text);
166 #else
167 *title = strdup(scan_comment->text);
168 #endif
169 }
170 }
171
172 /* Get Description */
173 if ( description != NULL )
174 {
175 if (work_error->description== NULL)
176 {
177 *description = NULL;
178 }
179 else
180 {
181 scan_comment = analyse_get_right_comment(work_error->description,language,ANALYSE_ENGLISH);
182 *description = analyse_fill_description(error_warning_type, scan_comment->text);
183 }
184 }
185
186 /* Get Comment */
187 if ( comment != NULL )
188 {
189 if (work_error->comment== NULL)
190 {
191 *comment = NULL;
192 }
193 else
194 {
195 scan_comment = analyse_get_right_comment(work_error->comment,language,ANALYSE_ENGLISH);
196 #ifdef _WIN64
197 *comment = _strdup(scan_comment->text);
198 #else
199 *comment = strdup(scan_comment->text);
200 #endif
201 }
202 }
203 }
204}
analyse_comment_t * analyse_get_right_comment(analyse_comment_t *start_comment, int language, int default_language)
char * analyse_fill_description(int object_type, char *description)
#define ANALYSE_ENGLISH
analyse_comment_t * description
analyse_comment_t * title
analyse_comment_t * comment

◆ analyse_error_set_tmp_cnt()

void analyse_error_set_tmp_cnt ( analyse_error_info_t * error_list,
int id,
int value )

Definition at line 89 of file analyse_error.c.

90{
91 analyse_error_info_t tmp_error;
92 analyse_error_info_t *work_error;
93
94 /* Search Error */
95 tmp_error.id = id;
96 work_error = bsearch( &tmp_error, error_list, ANALYSE_NB_ERROR, sizeof(analyse_error_info_t), compar_error);
97
98 if (work_error != NULL)
99 {
100 work_error->tmp_cnt=value;
101 }
102}

◆ compar_error()

int compar_error ( const void * error_1_p,
const void * error_2_p )
static

Definition at line 40 of file analyse_error.c.

41{
42 analyse_error_info_t *error_1 = (analyse_error_info_t *)error_1_p;
43 analyse_error_info_t *error_2 = (analyse_error_info_t *)error_2_p;
44
45 if ( (error_1->id < 0) &&(error_2->id < 0)) return (error_2->id - error_1->id);
46 if (error_1->id < 0) return 1;
47 if (error_2->id < 0) return -1;
48
49 return (error_1->id - error_2->id);
50}

◆ error_create()

analyse_error_info_t * error_create ( int size)
static

Definition at line 52 of file analyse_error.c.

53{
54 int i=0;
55 analyse_error_info_t *error_info;
56
57 error_info = (analyse_error_info_t *)analyse_malloc(size*sizeof(analyse_error_info_t));
58
59 for ( i=0; i<size; i++)
60 {
61 (error_info+i)->id = -i-1;
62 (error_info+i)->global_cnt=0;
63 (error_info+i)->tmp_cnt=0;
64 (error_info+i)->title = NULL;
65 (error_info+i)->description = NULL;
66 (error_info+i)->comment = NULL;
67 }
68 return error_info;
69
70}
void * analyse_malloc(size_t size)

Variable Documentation

◆ ANALYSE_NB_ERROR

int ANALYSE_NB_ERROR =0
static

Definition at line 38 of file analyse_error.c.