OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
analyse_getall.h File Reference

Go to the source code of this file.

Functions

void analyse_fitline (char *line)
int analyse_getint (int *x, int ncount, char *line)
int analyse_getdouble (double *x, int ncount, char *line)
int analyse_getstring (char *str, int ncount, char *line)
int analyse_getline (char line[], FILE *infile, char *infilename, int *linecount)
int analyse_getline_with_dollars (char line[], FILE *infile, char *infilename, int *linecount)
int analyse_getcommentline (char *comment, FILE *infile, char *infilename, int *linecount)
int analyse_getlist_of_int (int *nb_elt, int **elt, FILE *infile, char *infilename, int *linecount)
int analyse_getlist_of_char (int *nb_elt, char ***elt, FILE *infile, char *infilename, int *linecount)
int analyse_getlist_of_char_2 (int *nb_elt, char ***elt, FILE *infile, char *infilename, int *linecount)
int analyse_getkey (int pos, char *line, char *name)
int analyse_getsize_of_enum (int *nb_line, int *nb_dataline, FILE *infile, char *infilename, int *linecount)

Function Documentation

◆ analyse_fitline()

void analyse_fitline ( char * line)

Definition at line 43 of file analyse_getall.c.

44{
45 int index,charcount;
46
47 char *blank = " ";
48
49 index = strlen(line);
50
51 if( *(line+index - 1) == '\n')
52 index = index - 1;
53 charcount = 80 - index;
54 if(charcount > 0)
55 {
56 strncpy(line+index,blank,charcount);
57 }
58 *(line+80)='\0';
59}

◆ analyse_getcommentline()

int analyse_getcommentline ( char * comment,
FILE * infile,
char * infilename,
int * linecount )

Definition at line 162 of file analyse_getall.c.

163{
164 long infile_save;
165
166 char line[ANALYSE_SIZE_OF_LINE];
167 char tline[ANALYSE_SIZE_OF_LINE];
168
169 infile_save = ftell(infile);
170
171 if(fgets(line,ANALYSE_SIZE_OF_LINE,infile) == NULL)
172 {
173 sprintf(tline, "\n*** ERROR: premature EOF line: %d, File: %s ***\n\n\n",*linecount,infilename);
175 return(-1);
176 }
177
178 if ( (strncmp(line, "#include", 8) == 0) || (strncmp(line, "#enddata", 8) == 0))
179 {
180 sprintf(tline," *** Read Error : #include or #enddata inside a block in File %s at line %d\n\n***",infilename, *linecount);
182 return(-1);
183 }
184
185 if( ( *line == '#') && (strncmp(line, "#-", 2) != 0) )
186 {
187 analyse_fitline(line);
189 strcpy(comment, line);
190 *linecount = (*linecount)+1;
191 }
192 else
193 {
194 fseek(infile,infile_save,0);
195 }
196
197 return(0);
198}
#define ANALYSE_SIZE_OF_LINE
void analyse_fitline(char *line)
void Analyse_Print_Error_Level(char *text, int level)
char * analyse_string_fit_end(char *name)

◆ analyse_getdouble()

int analyse_getdouble ( double * x,
int ncount,
char * line )

Definition at line 82 of file analyse_getall.c.

84{
85 int readret;
86 char linecopy[21];
87
88 #ifdef _WIN64
89 strncpy_s(linecopy,21,line,ncount);
90 #else
91 strncpy(linecopy,line,ncount);
92 #endif
93 *(linecopy+ncount)='\0';
94 readret = sscanf(linecopy,"%lf",x);
95 if(readret < 0)
96 {
97 *x=0;
98 return(0);
99 }
100 return(readret);
101}

◆ analyse_getint()

int analyse_getint ( int * x,
int ncount,
char * line )

Definition at line 62 of file analyse_getall.c.

64{
65 int readret;
66 char linecopy[21];
67 #ifdef _WIN64
68 strncpy_s(linecopy,21,line,ncount);
69 #else
70 strncpy(linecopy,line,ncount);
71 #endif
72 *(linecopy+ncount)='\0';
73 readret = sscanf(linecopy,"%d",x);
74 if(readret < 0)
75 {
76 *x=0;
77 return(0);
78 }
79 return(readret);
80}

◆ analyse_getkey()

int analyse_getkey ( int pos,
char * line,
char * name )

Definition at line 501 of file analyse_getall.c.

502{
503 char *point_pos;
504 char *point_next;
505
506 int count = 0;
507 char *scan;
508
509 scan = line;
510
511 while ( count < pos )
512 {
513 point_pos=strchr(scan,'/');
514 if ( point_pos == NULL) return (-1);
515 scan = point_pos+1;
516 count = count+1;
517 }
518
519 point_next= strchr(scan,'/');
520 if ( point_next == NULL)
521 strcpy(name, scan);
522 else
523 {
524 strncpy(name, scan, point_next - point_pos -1);
525 name[point_next - point_pos -1]='\0';
526 }
527
529
530
531 return (0);
532}
char * analyse_string_fit_start_end(char *name)

◆ analyse_getline()

int analyse_getline ( char line[],
FILE * infile,
char * infilename,
int * linecount )

Definition at line 116 of file analyse_getall.c.

117{
118 char tline[ANALYSE_SIZE_OF_LINE];
119 do
120 {
121 if(fgets(line,ANALYSE_SIZE_OF_LINE,infile) == NULL)
122 {
123 sprintf(tline, "\n*** ERROR: premature EOF line: %d, File: %s ***\n\n\n",*linecount,infilename);
125 return(-1);
126 }
127 *linecount = (*linecount) + 1;
128
129 if(!strncmp(line, "#include", 8) || !strncmp(line, "#enddata", 8))
130 {
131 break;
132 }
133 } while (( *line == '#' ) || ( *line == '$'));
134
135 analyse_fitline(line);
136 return(0);
137}

◆ analyse_getline_with_dollars()

int analyse_getline_with_dollars ( char line[],
FILE * infile,
char * infilename,
int * linecount )

Definition at line 139 of file analyse_getall.c.

140{
141 char tline[ANALYSE_SIZE_OF_LINE];
142 do
143 {
144 if(fgets(line,ANALYSE_SIZE_OF_LINE,infile) == NULL)
145 {
146 sprintf(tline, "\n*** ERROR: premature EOF line: %d, File: %s ***\n\n\n",*linecount,infilename);
148 return(-1);
149 }
150 *linecount = (*linecount) + 1;
151
152 if(!strncmp(line, "#include", 8) || !strncmp(line, "#enddata", 8))
153 {
154 break;
155 }
156 } while ( *line == '#' );
157
158 analyse_fitline(line);
159 return(0);
160}

◆ analyse_getlist_of_char()

int analyse_getlist_of_char ( int * nb_elt,
char *** elt,
FILE * infile,
char * infilename,
int * linecount )

Definition at line 299 of file analyse_getall.c.

300{
301 char line[ANALYSE_SIZE_OF_LINE];
302
303 long infile_save;
304 int linecount_save;
305
306 int stop_flag = 0;
307 int elt_count = 0;
308
309 char **elt_tmp;
310
311 int i = 0;
312
313#ifdef ANALYSE_DEBUG
314 sprintf(tline,"Entering analyse_getlist_of_char at line %d\n",*linecount);
315 Analyse_Print_Debug(tline);
316#endif
317
318 elt_tmp = (char **) analyse_malloc(10*sizeof( char *));
319
320 while(!stop_flag)
321 {
322 infile_save = ftell(infile);
323 linecount_save=*linecount;
324
325 /* if trouble in reading line, then exit */
326 if(analyse_getline(line,infile,infilename,linecount))
327 {
328 analyse_free(elt_tmp);
329 *elt= NULL;
330 *nb_elt=0;
331 return (-1);
332 }
333
334 /* if new line is start of a new block, exit */
335 if ( ( *line == '/' ) || (strncmp(line, "#include", 8) == 0) || (strncmp(line, "#enddata", 8) == 0) )
336 {
337 fseek(infile,infile_save,0);
338 *linecount = linecount_save;
339 stop_flag = 1;
340 continue;
341 }
342
343 /* if comment line, forget it */
344 if ( ( *line == '#' ) || ( *line == '$' ))
345 continue;
346
347
348 for(i=0;i<10;i++)
349 {
350 *(elt_tmp+elt_count) = (char *) analyse_malloc(9*sizeof(char));
351 analyse_getstring(*(elt_tmp+elt_count),8,line+8*i);
352 if (strlen(*(elt_tmp+elt_count)) == 0)
353 {
354 analyse_free(*(elt_tmp+elt_count));
355 stop_flag = 1;
356 break;
357 }
358 else
359 {
360 elt_count = elt_count+1;
361 }
362 }
363
364 if ( i == 10) /* if we read a whole line, prepare memory for the next one */
365 elt_tmp = (char **) analyse_realloc(elt_tmp, (size_t) ((elt_count+10) * sizeof( char *)));
366
367 }
368
369 *nb_elt= elt_count;
370
371 if ( *nb_elt == 0)
372 {
373 analyse_free(elt_tmp);
374 *elt = NULL;
375 }
376 else
377 {
378 elt_tmp = (char **) analyse_realloc(elt_tmp, (size_t) ( (*nb_elt) * sizeof( char *)));
379 *elt= elt_tmp;
380 }
381
382#ifdef ANALYSE_DEBUG
383 sprintf(tline,"Exit analyse_getlist_of_char at line %d, with %d elts\n",*linecount,*nb_elt);
384 Analyse_Print_Debug(tline);
385#endif
386
387 return(0);
388}
int analyse_getline(char line[], FILE *infile, char *infilename, int *linecount)
int analyse_getstring(char *str, int ncount, char *line)
void * analyse_malloc(size_t size)
void analyse_free(void *block)
void * analyse_realloc(void *block, size_t size)
void Analyse_Print_Debug(char *text)

◆ analyse_getlist_of_char_2()

int analyse_getlist_of_char_2 ( int * nb_elt,
char *** elt,
FILE * infile,
char * infilename,
int * linecount )

Definition at line 396 of file analyse_getall.c.

397{
398 char line[ANALYSE_SIZE_OF_LINE];
399
400 long infile_save;
401 int linecount_save;
402
403 int stop_flag = 0;
404 int elt_count = 0;
405
406 char **elt_tmp;
407 char *tmp;
408
409 int i = 0;
410
411#ifdef ANALYSE_DEBUG
412 sprintf(tline,"Entering analyse_getlist_of_char at line %d\n",*linecount);
413 Analyse_Print_Debug(tline);
414#endif
415
416 elt_tmp = (char **) analyse_malloc(10*sizeof( char *));
417
418 while(!stop_flag)
419 {
420 infile_save = ftell(infile);
421 linecount_save=*linecount;
422
423 /* if trouble in reading line, then exit */
424 if(analyse_getline(line,infile,infilename,linecount))
425 {
426 analyse_free(elt_tmp);
427 *elt= NULL;
428 *nb_elt=0;
429 return (-1);
430 }
431
432 /* if new line is start of a new block, exit */
433 if ( ( *line == '/' ) || (strncmp(line, "#include", 8) == 0) || (strncmp(line, "#enddata", 8) == 0) )
434 {
435 fseek(infile,infile_save,0);
436 *linecount = linecount_save;
437 stop_flag = 1;
438 continue;
439 }
440
441 /* if comment line, forget it */
442 if ( ( *line == '#' ) || ( *line == '$' ))
443 continue;
444
445
446 for(i=0;i<10;i++)
447 {
448 *(elt_tmp+elt_count) = (char *) analyse_malloc(9*sizeof(char));
449 analyse_getstring(*(elt_tmp+elt_count),8,line+8*i);
450 if (strlen(*(elt_tmp+elt_count)) == 0)
451 {
452 analyse_free(*(elt_tmp+elt_count));
453 stop_flag = 1;
454 break;
455 }
456 else
457 {
458 if ( ( elt_count > 0) &&
459 (*(elt_tmp+elt_count))[0] == '@' )
460 {
461 tmp = (char *) analyse_malloc( (strlen(*(elt_tmp+elt_count-1))+strlen(*(elt_tmp+elt_count)))*sizeof(char));
462 strcpy(tmp, *(elt_tmp+elt_count-1));
463 strcat(tmp, *(elt_tmp+elt_count) +1);
464 analyse_free(*(elt_tmp+elt_count-1));
465 analyse_free(*(elt_tmp+elt_count));
466 *(elt_tmp+elt_count-1) = tmp;
467 }
468 else
469 {
470 elt_count = elt_count+1;
471 }
472 }
473 }
474
475 if ( i == 10) /* if we read a whole line, prepare memory for the next one */
476 elt_tmp = (char **) analyse_realloc(elt_tmp, (size_t) ((elt_count+10) * sizeof( char *)));
477
478 }
479
480 *nb_elt= elt_count;
481
482 if ( *nb_elt == 0)
483 {
484 analyse_free(elt_tmp);
485 *elt = NULL;
486 }
487 else
488 {
489 elt_tmp = (char **) analyse_realloc(elt_tmp, (size_t) ( (*nb_elt) * sizeof( char *)));
490 *elt= elt_tmp;
491 }
492
493#ifdef ANALYSE_DEBUG
494 sprintf(tline,"Exit analyse_getlist_of_char at line %d, with %d elts\n",*linecount,*nb_elt);
495 Analyse_Print_Debug(tline);
496#endif
497
498 return(0);
499}

◆ analyse_getlist_of_int()

int analyse_getlist_of_int ( int * nb_elt,
int ** elt,
FILE * infile,
char * infilename,
int * linecount )

Definition at line 205 of file analyse_getall.c.

206{
207 char line[ANALYSE_SIZE_OF_LINE];
208
209 long infile_save;
210 int linecount_save;
211
212 int stop_flag = 0;
213 int elt_count = 0;
214
215 int *elt_tmp = NULL;
216
217 int i = 0;
218
219#ifdef ANALYSE_DEBUG
220 sprintf(tline,"Entering analyse_getlist_of_int at line %d\n",*linecount);
221 Analyse_Print_Debug(tline);
222#endif
223
224
225 elt_tmp = (int *) analyse_malloc(10*sizeof(int));
226
227 while(!stop_flag)
228 {
229 infile_save = ftell(infile);
230 linecount_save=*linecount;
231
232 /* if trouble in reading line, then exit */
233 if(analyse_getline(line,infile,infilename,linecount))
234 {
235 analyse_free(elt_tmp);
236 *elt = NULL;
237 *nb_elt=0;
238 return (-1);
239 }
240
241 /* if new line is start of a new block, exit */
242 if ( ( *line == '/' ) || (strncmp(line, "#include", 8) == 0) || (strncmp(line, "#enddata", 8) == 0) )
243 {
244 fseek(infile,infile_save,0);
245 *linecount = linecount_save;
246 stop_flag = 1;
247 continue;
248 }
249
250 /* if comment line, forget it */
251 if ( ( *line == '#' ) || ( *line == '$') )
252 continue;
253
254 for(i=0;i<10;i++)
255 {
256 if((!analyse_getint(elt_tmp+elt_count,8,line+8*i)) || (elt_tmp[elt_count] == 0))
257 {
258 stop_flag = 1;
259 break;
260 }
261 else
262 {
263 elt_count = elt_count+1;
264 }
265 }
266
267 if ( i == 10)
268 elt_tmp= (int *) analyse_realloc(elt_tmp, (size_t) ((elt_count+10) * sizeof(int)));
269
270 }
271
272 *nb_elt= elt_count;
273
274 if (*nb_elt == 0)
275 {
276 analyse_free(elt_tmp);
277 *elt=NULL;
278 }
279 else
280 {
281 elt_tmp = (int *) analyse_realloc(elt_tmp, (size_t) ((*nb_elt) * sizeof(int)));
282 *elt= elt_tmp;
283 }
284
285#ifdef ANALYSE_DEBUG
286 sprintf(tline,"Exit analyse_getlist_of_int at line %d, with %d elts\n",*linecount,*nb_elt);
287 Analyse_Print_Debug(tline);
288#endif
289
290
291 return(0);
292}
int analyse_getint(int *x, int ncount, char *line)

◆ analyse_getsize_of_enum()

int analyse_getsize_of_enum ( int * nb_line,
int * nb_dataline,
FILE * infile,
char * infilename,
int * linecount )

Definition at line 538 of file analyse_getall.c.

539{
540 char line[ANALYSE_SIZE_OF_LINE];
541 char tline[ANALYSE_SIZE_OF_LINE];
542
543 long infile_save;
544 int linecount_save;
545
546 *nb_line = 0;
547 *nb_dataline = 0;
548
549#ifdef ANALYSE_DEBUG
550 sprintf(tline, " Entering analyse_getsize_of_enum at line %d\n",*linecount);
551 Analyse_Print_Debug(tline);
552#endif
553
554 infile_save = ftell(infile);
555 linecount_save= *linecount;
556
557 do
558 {
559 if(fgets(line,ANALYSE_SIZE_OF_LINE,infile) == NULL)
560 {
561 sprintf(tline, "\n*** ERROR: premature EOF line: %d, File: %s ***\n\n\n", ( *linecount+1) ,infilename);
563 return(-1);
564 }
565
566 if ( ( *line == '/' ) || (strncmp(line, "#include", 8) == 0) || (strncmp(line, "#enddata", 8) == 0) )
567 {
568 fseek(infile,infile_save,0);
569 *linecount= linecount_save;
570
571#ifdef ANALYSE_DEBUG
572 sprintf(tline, " Exit analyse_getsize_of_enum with nb_line = %d, and nb_dataline = %d\n",*nb_line,*nb_dataline);
573 Analyse_Print_Debug(tline);
574#endif
575 return (0);
576 }
577
578 /* if no comment line, one more data */
579 if ( ( *line != '#' ) && ( *line != '$') )
580 {
581 *nb_dataline = (*nb_dataline)+1;
582 }
583
584 *nb_line = (*nb_line)+1;
585 *linecount = (*linecount)+1;
586
587 } while (1);
588
589}

◆ analyse_getstring()

int analyse_getstring ( char * str,
int ncount,
char * line )

Definition at line 104 of file analyse_getall.c.

105{
106 strncpy(str,line,ncount);
107 *(str+ncount)='\0';
108
110 return(0);
111}