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

Go to the source code of this file.

Functions

static int compar_check_group (const void *group_1_p, const void *group_2_p)
static int compar_check_group_by_order (const void *group_1_p, const void *group_2_p)
static int compar_check (const void *check_1_p, const void *check_2_p)
static analyse_check_group_tcheck_group_create (int nb_check_group)
static analyse_check_tcheck_create (int nb_check)
void analyse_check_store (analyse_check_t *check_list, int language, int id)
void analyse_check_file_read (analyse_check_t **check_p, analyse_check_group_t **check_group_p, char *infilename)
void analyse_check_file_write (analyse_check_t *check_list, analyse_check_group_t *check_group_list, int language)
void analyse_check_clean_memory (analyse_check_t *check_list, analyse_check_group_t *check_group_list)

Variables

static int ANALYSE_NB_CHECK_GROUP =0
static int ANALYSE_NB_CHECK =0

Function Documentation

◆ analyse_check_clean_memory()

void analyse_check_clean_memory ( analyse_check_t * check_list,
analyse_check_group_t * check_group_list )

Definition at line 372 of file analyse_check.c.

373{
374
375
376}

◆ analyse_check_file_read()

void analyse_check_file_read ( analyse_check_t ** check_p,
analyse_check_group_t ** check_group_p,
char * infilename )

Definition at line 152 of file analyse_check.c.

153{
154 FILE *infile=NULL;
155 char line[ANALYSE_SIZE_OF_LINE];
156 char key[ANALYSE_SIZE_OF_LINE];
157 int i, id;
158 int linecount = 0;
159
160 analyse_comment_t *comment;
161
162 analyse_check_t *work_check;
163 analyse_check_t tmp_check;
164
165 analyse_check_group_t *work_check_group;
166 analyse_check_group_t tmp_check_group;
167
168 int count_check_group = 0;
169 int check_group_already_print = 0;
170
171 int count_check = 0;
172 int check_already_print = 0;
173
174 int nb_check, nb_check_group, size, size2;
175 int *tab, *tab2;
176
177 int nb_elt;
178 int *elt;
179
180 /*************/
181 /* Open File */
182 /*************/
183 if (infilename != NULL)
184 {
185 infile = fopen(infilename,"r");
186 }
187
188 if (infile == NULL)
189 {
190 Analyse_Print_Debug("\nNo Check File Found. Use Default\n\n");
191
192
193 return;
194 }
195
196
197 /***************************/
198 /* Allocate Message Memory */
199 /***************************/
200
201 /* Count message */
202 analyse_count_check(line, infile, infilename, &linecount, &nb_check, &nb_check_group);
203 rewind(infile);
204 analyse_stack_check(line, infile, infilename, &linecount, &nb_check_group, &size, &tab, &nb_check, &size2, &tab2 );
205
206 ANALYSE_NB_CHECK_GROUP = nb_check_group;
207 ANALYSE_NB_CHECK = nb_check;
208
209 analyse_free(tab);
210 analyse_free(tab2);
211
212 *check_p = check_create(ANALYSE_NB_CHECK);
214
215
216 /****************/
217 /* Read Message */
218 /****************/
219 rewind(infile);
220 while ( ( analyse_getline(line, infile, infilename, &linecount) != -1) &&
221 ( strncmp(line, "/END", 4) != 0 ))
222 {
223 if (strstr(line, "/ANALYSE/CHECK/GROUP") != NULL)
224 {
225 /* Search Group id */
226 analyse_getkey(4 , line, key);
227 sscanf(key, "%d", &id );
228
229 /* Search id */
230 tmp_check_group.id = id;
231 work_check_group = bsearch( &tmp_check_group, *check_group_p, ANALYSE_NB_CHECK_GROUP, sizeof(analyse_check_group_t), compar_check_group);
232
233 if ( work_check_group == NULL)
234 {
235 if (count_check_group >= ANALYSE_NB_CHECK_GROUP)
236 {
237 if ( check_group_already_print == 0)
238 {
239 Analyse_Print_Error_Level("\n\n*** Analyse Internal Error (ANALYSE_NB_CHECK_GROUP) : Too Many Messages \n\n", 2);
240 check_group_already_print = 1;
241 }
242 continue;
243 }
244
245 work_check_group = *check_group_p + count_check_group;
246
247 work_check_group->order = count_check_group;
248 work_check_group->id = id;
249
250 /* Note : if file order is in id increase, this qsort does nothing ... */
252 tmp_check_group.id = id;
253 /* .. and this bsearch gives the same work_group */
254 work_check_group = bsearch( &tmp_check_group, *check_group_p, ANALYSE_NB_CHECK_GROUP, sizeof(analyse_check_group_t), compar_check_group);
255
256 count_check_group++;
257 }
258
259 analyse_getkey(5 , line, key);
260
261 if (strncmp(key, "TITLE", 5) == 0)
262 {
263 /* Read Comment */
264 comment = analyse_read_comment(line, infile, infilename, &linecount);
265 analyse_add_comment(ANALYSE_CHECK_GROUP, (void *)work_check_group, comment);
266 }
267 else if (strncmp(key, "DESCRIPTION", 5) == 0)
268 {
269 /* Read list of ids */
270 if ( analyse_getlist_of_int(&nb_elt, &elt, infile, infilename, &linecount) == 0)
271 {
272 work_check_group->check_list = (int *)analyse_realloc(work_check_group->check_list, (work_check_group->nb_check + nb_elt)*sizeof(int));
273 work_check_group->check_message = (char **)analyse_realloc(work_check_group->check_message, (work_check_group->nb_check + nb_elt)*sizeof(char *));
274
275 for(i=0; i<nb_elt; i++)
276 {
277 work_check_group->check_list[work_check_group->nb_check + i] = elt[i];
278 work_check_group->check_message[work_check_group->nb_check + i] = NULL;
279 }
280 analyse_free(elt);
281 work_check_group->nb_check = work_check_group->nb_check + nb_elt;
282 }
283 }
284 }
285 else if (strstr(line, "/ANALYSE/CHECK") != NULL)
286 {
287 analyse_getkey(3 , line, key);
288 sscanf(key, "%d", &id );
289
290 /* Search id */
291 tmp_check.id = id;
292 work_check = bsearch( &tmp_check, *check_p, ANALYSE_NB_CHECK, sizeof(analyse_check_t), compar_check);
293
294 if ( work_check == NULL)
295 {
296 if (count_check >= ANALYSE_NB_CHECK)
297 {
298 if ( check_already_print == 0)
299 {
300 Analyse_Print_Error_Level("\n\n*** Analyse Internal Error (ANALYSE_NB_CHECK) : Too Many Messages \n\n", 2);
301 check_already_print = 1;
302 }
303 continue;
304 }
305
306 work_check = *check_p + count_check;
307 count_check++;
308
309 work_check->id = id;
310
311 /* Note : if file order is in id increase, this qsort does nothing ... */
313 tmp_check.id = id;
314 /* .. and this bsearch gives the same work_check */
315 work_check = bsearch( &tmp_check, *check_p, ANALYSE_NB_CHECK, sizeof(analyse_check_t), compar_check);
316
317 }
318
319 /* Read Comment */
320 comment = analyse_read_comment(line, infile, infilename, &linecount);
321 analyse_add_comment(ANALYSE_CHECK, (void *)work_check, comment);
322
323 }
324 }
325
326 fclose(infile);
327
328}
static int compar_check(const void *check_1_p, const void *check_2_p)
static int ANALYSE_NB_CHECK_GROUP
static analyse_check_group_t * check_group_create(int nb_check_group)
static analyse_check_t * check_create(int nb_check)
static int ANALYSE_NB_CHECK
static int compar_check_group(const void *group_1_p, const void *group_2_p)
struct analyse_check_group_s analyse_check_group_t
struct analyse_check_s analyse_check_t
void analyse_add_comment(int object_type, void *object, analyse_comment_t *comment)
struct analyse_comment_s analyse_comment_t
#define ANALYSE_CHECK
#define ANALYSE_CHECK_GROUP
#define ANALYSE_SIZE_OF_LINE
int analyse_getkey(int pos, char *line, char *name)
int analyse_getlist_of_int(int *nb_elt, int **elt, FILE *infile, char *infilename, int *linecount)
int analyse_getline(char line[], FILE *infile, char *infilename, int *linecount)
void analyse_free(void *block)
void * analyse_realloc(void *block, size_t size)
void Analyse_Print_Error_Level(char *text, int level)
void Analyse_Print_Debug(char *text)
void analyse_count_check(char *line, FILE *infile, char *infilename, int *linecount_p, int *cnt_check_p, int *cnt_group_p)
analyse_comment_t * analyse_read_comment(char *line, FILE *infile, char *filename, int *linecount_p)
void analyse_stack_check(char *line, FILE *infile, char *infilename, int *linecount_p, int *nb_check_group_p, int *size_p, int **tab_p, int *nb_check_p, int *size2_p, int **tab2_p)
recursive subroutine qsort(a, idx, first, last)
initmumps id

◆ analyse_check_file_write()

void analyse_check_file_write ( analyse_check_t * check_list,
analyse_check_group_t * check_group_list,
int language )

Definition at line 330 of file analyse_check.c.

331{
332 int i,j, nb_check;
333
334 analyse_comment_t *scan_comment;
335
336 analyse_check_group_t *work_check_group;
337
338 analyse_check_t tmp_check;
339 analyse_check_t *work_check;
340
341 /* re order groups by order appearance in file, and no more by id */
343
344 for (i=0; i<ANALYSE_NB_CHECK_GROUP; i++)
345 {
346 work_check_group = check_group_list+i;
347 nb_check = work_check_group->nb_check;
348
349 scan_comment = analyse_get_right_comment( work_check_group->title, language, ANALYSE_ENGLISH);
350
351 if ((scan_comment != NULL) && (scan_comment->text != NULL))
352 {
353 analyse_write_f("\n\n");
354 analyse_write_f(scan_comment->text);
355 /* analyse_write_f("\n"); */
356 }
357
358 for( j=0; j<nb_check; j++)
359 {
360 tmp_check.id = work_check_group->check_list[j];
361 work_check = bsearch( &tmp_check, check_list, ANALYSE_NB_CHECK, sizeof(analyse_check_t), compar_check);
362
363 if ((work_check != NULL) && (work_check->check_message!= NULL))
364 {
365 analyse_write_f(work_check->check_message);
366 /* analyse_write_f("\n"); */
367 }
368 }
369 }
370}
void analyse_write_f(char *message)
Definition analyse.c:1022
static int compar_check_group_by_order(const void *group_1_p, const void *group_2_p)
analyse_comment_t * analyse_get_right_comment(analyse_comment_t *start_comment, int language, int default_language)
#define ANALYSE_ENGLISH
analyse_comment_t * title

◆ analyse_check_store()

void analyse_check_store ( analyse_check_t * check_list,
int language,
int id )

Definition at line 118 of file analyse_check.c.

119{
120 analyse_comment_t *scan_comment;
121 analyse_check_t tmp_check;
122 analyse_check_t *work_check;
123
124 char line[ANALYSE_SIZE_OF_LINE];
125
126 /* Search id */
127 tmp_check.id = id;
128 work_check = bsearch( &tmp_check, check_list, ANALYSE_NB_CHECK, sizeof(analyse_check_t), compar_check);
129
130 if ( work_check == NULL)
131 {
132 sprintf(line, "Unknown Id for Check %d\nNo Message Available\n", id );
134 }
135
136 if ( work_check->check_message != NULL )
137 {
138 analyse_free(work_check->check_message);
139 work_check->check_message = NULL;
140 }
141
142 scan_comment = analyse_get_right_comment( work_check->title, language, ANALYSE_ENGLISH);
143
144 work_check->check_message = analyse_fill_description(AN_CHECK, scan_comment->text);
145
146}
char * analyse_fill_description(int object_type, char *description)
analyse_comment_t * title

◆ check_create()

analyse_check_t * check_create ( int nb_check)
static

Definition at line 100 of file analyse_check.c.

101{
102 analyse_check_t *check;
103 int i;
104
105 check = (analyse_check_t *)analyse_malloc(nb_check*sizeof(analyse_check_t));
106
107 for(i=0; i<nb_check; i++)
108 {
109 (check+i)->id = -i-1;
110 (check+i)->title = NULL;
111 (check+i)->check_message = NULL;
112 }
113
114 return check;
115}
void * analyse_malloc(size_t size)

◆ check_group_create()

analyse_check_group_t * check_group_create ( int nb_check_group)
static

Definition at line 80 of file analyse_check.c.

81{
82 analyse_check_group_t *check_group;
83 int i;
84
85 check_group = (analyse_check_group_t *)analyse_malloc(nb_check_group*sizeof(analyse_check_group_t));
86
87 for(i=0; i<nb_check_group; i++)
88 {
89 (check_group+i)->order = 0;
90 (check_group+i)->id = -i-1;
91 (check_group+i)->title = NULL;
92 (check_group+i)->nb_check = 0;
93 (check_group+i)->check_list = NULL;
94 (check_group+i)->check_message = NULL;
95 }
96
97 return check_group;
98}

◆ compar_check()

int compar_check ( const void * check_1_p,
const void * check_2_p )
static

Definition at line 67 of file analyse_check.c.

68{
69 analyse_check_t *check_1 = (analyse_check_t *)check_1_p;
70 analyse_check_t *check_2 = (analyse_check_t *)check_2_p;
71
72 if ( (check_1->id < 0) &&(check_2->id < 0)) return (check_2->id - check_1->id);
73 if (check_1->id < 0) return 1;
74 if (check_2->id < 0) return -1;
75
76 return (check_1->id - check_2->id);
77}

◆ compar_check_group()

int compar_check_group ( const void * group_1_p,
const void * group_2_p )
static

Definition at line 43 of file analyse_check.c.

44{
45 analyse_check_group_t *group_1 = (analyse_check_group_t *)group_1_p;
46 analyse_check_group_t *group_2 = (analyse_check_group_t *)group_2_p;
47
48 if ( (group_1->id < 0) &&(group_2->id < 0)) return (group_2->id - group_1->id);
49 if (group_1->id < 0) return 1;
50 if (group_2->id < 0) return -1;
51
52 return (group_1->id - group_2->id);
53}

◆ compar_check_group_by_order()

int compar_check_group_by_order ( const void * group_1_p,
const void * group_2_p )
static

Definition at line 55 of file analyse_check.c.

56{
57 analyse_check_group_t *group_1 = (analyse_check_group_t *)group_1_p;
58 analyse_check_group_t *group_2 = (analyse_check_group_t *)group_2_p;
59
60 if ( (group_1->order < 0) &&(group_2->order < 0)) return (group_2->order - group_1->order);
61 if (group_1->order < 0) return 1;
62 if (group_2->order < 0) return -1;
63
64 return (group_1->order - group_2->order);
65}

Variable Documentation

◆ ANALYSE_NB_CHECK

int ANALYSE_NB_CHECK =0
static

Definition at line 41 of file analyse_check.c.

◆ ANALYSE_NB_CHECK_GROUP

int ANALYSE_NB_CHECK_GROUP =0
static

Definition at line 40 of file analyse_check.c.