00001 #include "cmlfile.h"
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 #include <string.h>
00005
00006 #define BufferLength 1024
00007 #define KeywordLength 64
00008 #define MaxFiles 16
00009 #define DefaultDoubleFormat "%10.10E"
00010
00011 #define KeywordSection "SECTION"
00012 #define KeywordEndSection "END"
00013 #define KeywordFile "FILE"
00014
00015
00016 #define None -1
00017 #define Comment -2
00018 #define File -3
00019 #define Section -4
00020 #define EndSection -5
00021
00022 #define Required 1
00023 #define Optional 0
00024 #define Refused -1
00025
00026 long read_to_eoln ( FILE *ofile , char *obuffer )
00027 {
00028 if ( !fgets( obuffer,BufferLength,ofile ))
00029 {
00030 return None ;
00031 }
00032 long i=0 ;
00033 while ( obuffer[i] )
00034 {
00035 i++ ;
00036 }
00037 obuffer[i-1]=0 ;
00038 return 1 ;
00039 }
00040
00041 long str_equal ( const char *opattern , const char *ostring )
00042 {
00043 long i=0 ;
00044 while ( opattern[i] )
00045 {
00046 if ( opattern[i]!=ostring[i] )
00047 {
00048 return 0 ;
00049 }
00050 i++ ;
00051 }
00052 return 1 ;
00053 }
00054
00055 long read_string ( FILE *ofile , char *obuffer )
00056 {
00057 long i,j ;
00058 j=fscanf( ofile,"%s",obuffer ) ;
00059
00060 if ( j!=1 )
00061 {
00062 return j ;
00063 }
00064 if ( obuffer[0]!='"' )
00065 {
00066 return 1 ;
00067 }
00068 i=0 ;
00069 while ( obuffer[i] )
00070 {
00071 i++ ;
00072 }
00073 if ( obuffer[i-1]=='"' )
00074 {
00075 obuffer[i-1]=0 ;
00076 memcpy( obuffer,obuffer+1,i ) ;
00077 return 1 ;
00078 }
00079 char c ;
00080 do
00081 {
00082 c=fgetc( ofile ) ;
00083 if ( c==EOF )
00084 {
00085 return -1 ;
00086 }
00087 obuffer[i]=c ;
00088 i++ ;
00089 }
00090 while ( c!='"' ) ;
00091 obuffer[i-1]=0 ;
00092 memcpy( obuffer,obuffer+1,i ) ;
00093 return 1 ;
00094 }
00095
00096 struct keyword
00097 {
00098 long *file,*position ;
00099 long i,n,req ;
00100 char *word ;
00101 keyword ( void ) ;
00102 ~keyword ( void ) ;
00103 void copy ( keyword &ok ) ;
00104 } ;
00105
00106 keyword::keyword ( void )
00107 {
00108 file=NULL ;
00109 position=NULL ;
00110 word=new char[KeywordLength] ;
00111 i=0 ;
00112 n=0 ;
00113 req=Optional ;
00114 }
00115
00116 keyword::~keyword ( void )
00117 {
00118 if ( file )
00119 {
00120 delete [] file ;
00121 }
00122 if ( position )
00123 {
00124 delete [] position ;
00125 }
00126 if ( word )
00127 {
00128 delete [] word ;
00129 }
00130 }
00131
00132 void keyword::copy ( keyword &ok )
00133 {
00134 req=ok.req ;
00135 memcpy( word,ok.word,KeywordLength ) ;
00136 }
00137
00138 struct section
00139 {
00140 char *word ;
00141 long *pos,*rows,*file,*end ;
00142 long files,rows_all,actual,i,req ;
00143 int last_pos;
00144 section ( void ) ;
00145 ~section ( void ) ;
00146 void copy ( section &os ) ;
00147 } ;
00148
00149 section::section ( void )
00150 {
00151 pos=new long[MaxFiles] ;
00152 rows=new long[MaxFiles] ;
00153 file=new long[MaxFiles] ;
00154 end=new long[MaxFiles] ;
00155 word=new char[KeywordLength] ;
00156 files=0 ;
00157 rows_all=0 ;
00158 actual=0 ;
00159 i=0 ;
00160 req=0 ;
00161 last_pos=0;
00162 }
00163
00164 section::~section ( void )
00165 {
00166 if ( pos )
00167 {
00168 delete [] pos ;
00169 }
00170 if ( rows )
00171 {
00172 delete [] rows ;
00173 }
00174 if ( file )
00175 {
00176 delete [] file ;
00177 }
00178 if ( end )
00179 {
00180 delete [] end ;
00181 }
00182 if ( word )
00183 {
00184 delete [] word ;
00185 }
00186 }
00187
00188 void section::copy ( section &os )
00189 {
00190 req=os.req ;
00191 memcpy( word,os.word,KeywordLength ) ;
00192 }
00193
00194 cmlfile::cmlfile ( void )
00195 {
00196 input=new PFILE[MaxFiles] ;
00197 long i ;
00198 for ( i=0 ; i<MaxFiles ; i++ )
00199 {
00200 input[i]=NULL ;
00201 }
00202 files=0 ;
00203 labels=0 ;
00204
00205 names=0 ;
00206 get_name=NULL ;
00207
00208 sections=0 ;
00209 stop=NULL ;
00210 block=NULL ;
00211 output=NULL ;
00212
00213 buffer=new char[BufferLength] ;
00214 double_format=new char[16] ;
00215 strcpy( double_format,DefaultDoubleFormat ) ;
00216
00217 clear_errors() ;
00218 normal_read_disable=0 ;
00219 requirement_insufficient=0 ;
00220 compiled=0 ;
00221 }
00222
00223 cmlfile::cmlfile ( const char *ofname )
00224 {
00225 input=new PFILE[MaxFiles] ;
00226 long i ;
00227 for ( i=0 ; i<MaxFiles ; i++ )
00228 {
00229 input[i]=NULL ;
00230 }
00231
00232 names=0 ;
00233 get_name=NULL ;
00234
00235 labels=0 ;
00236 sections=0 ;
00237 stop=NULL ;
00238 block=NULL ;
00239 output=NULL ;
00240
00241 buffer=new char[BufferLength] ;
00242 double_format=new char[16] ;
00243 strcpy( double_format,DefaultDoubleFormat ) ;
00244
00245 clear_errors() ;
00246 normal_read_disable=0 ;
00247 requirement_insufficient=0 ;
00248 compiled=0 ;
00249
00250 input[0]=fopen( ofname,"rt" ) ;
00251 if ( !input[0] )
00252 {
00253 printf( "Cannot open file %s.\n",ofname ) ;
00254 open_error=1 ;
00255 return ;
00256 }
00257 files=1 ;
00258 }
00259
00260 cmlfile::~cmlfile ( void )
00261 {
00262 long i ;
00263 for ( i=0 ; i<files ; i++ )
00264 {
00265 fclose( input[i] ) ;
00266 }
00267 delete [] input ;
00268 if ( output )
00269 {
00270 fclose( output ) ;
00271 }
00272 if ( buffer )
00273 {
00274 delete [] buffer ;
00275 }
00276 if ( double_format )
00277 {
00278 delete [] double_format ;
00279 }
00280 if ( stop )
00281 {
00282 delete [] stop ;
00283 }
00284 if ( block )
00285 {
00286 delete [] block ;
00287 }
00288
00289 if ( get_name )
00290 {
00291 delete [] get_name ;
00292 }
00293
00294 }
00295
00296
00297 void cmlfile::set_names ( long onames )
00298 {
00299 names=onames ;
00300 get_name=new keyword[onames] ;
00301 }
00302
00303 void cmlfile::set_name_string ( long oname , char *oname_string )
00304 {
00305 strcpy( get_name[oname].word,oname_string ) ;
00306 }
00307
00308 void cmlfile::get_value_from_name ( long olabel , long &ovalue )
00309 {
00310 char s[KeywordLength] ;
00311
00312 get_value( olabel,s ) ;
00313 ovalue=name( s ) ;
00314 }
00315
00316 void cmlfile::get_value_from_name ( long olabel , long oorder , long &ovalue )
00317 {
00318 char s[KeywordLength] ;
00319
00320 get_value( olabel,oorder,s ) ;
00321 ovalue=name( s ) ;
00322 }
00323
00324 void cmlfile::get_value_with_index_from_name ( long olabel , long oindex , long &ovalue )
00325 {
00326 char s[KeywordLength] ;
00327
00328 get_value_with_index( olabel, oindex, s ) ;
00329 ovalue=name( s ) ;
00330 }
00331
00332 void cmlfile::get_value_with_index_from_name ( long olabel , long oindex , long oorder , long &ovalue )
00333 {
00334 char s[KeywordLength] ;
00335
00336 get_value_with_index( olabel, oindex, oorder, s ) ;
00337 ovalue=name( s ) ;
00338 }
00339
00340 void cmlfile::get_section_value ( long olabel, long oline, long oorder, long &ovalue )
00341 {
00342 if ( !compiled )
00343 {
00344 compile() ;
00345 }
00346
00347 actual=block[olabel].file[0] ;
00348 fseek( input[actual],block[olabel].pos[0],SEEK_SET ) ;
00349 read_to_eoln( input[actual],buffer ) ;
00350
00351 long i, j ;
00352 for ( i=0 ; ( i<oline ) && ( i<block[olabel].rows_all ) ; i++ )
00353 {
00354 read_to_eoln( input[actual],buffer ) ;
00355 }
00356
00357 for ( i=0 ; i<oorder ; i++ )
00358 {
00359 read_string( input[actual],buffer ) ;
00360 }
00361 j=fscanf( input[actual],"%ld",&ovalue ) ;
00362
00363 if ( j!=1 )
00364 {
00365 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
00366 read_error=1 ;
00367 }
00368 }
00369
00370 void cmlfile::get_section_value ( long olabel, long oline, long oorder, double &ovalue )
00371 {
00372 if ( !compiled )
00373 {
00374 compile() ;
00375 }
00376
00377 actual=block[olabel].file[0] ;
00378 fseek( input[actual],block[olabel].pos[0],SEEK_SET ) ;
00379 read_to_eoln( input[actual],buffer ) ;
00380
00381 long i, j ;
00382 for ( i=0 ; ( i<oline ) && ( i<block[olabel].rows_all ) ; i++ )
00383 {
00384 read_to_eoln( input[actual],buffer ) ;
00385 }
00386
00387 for ( i=0 ; i<oorder ; i++ )
00388 {
00389 read_string( input[actual],buffer ) ;
00390 }
00391 j=fscanf( input[actual],"%lf",&ovalue ) ;
00392
00393 if ( j!=1 )
00394 {
00395 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
00396 read_error=1 ;
00397 }
00398 }
00399
00400 void cmlfile::get_section_value ( long olabel, long oline, long oorder, char *ovalue )
00401 {
00402 if ( !compiled )
00403 {
00404 compile() ;
00405 }
00406
00407 actual=block[olabel].file[0] ;
00408 fseek( input[actual],block[olabel].pos[0],SEEK_SET ) ;
00409 read_to_eoln( input[actual],buffer ) ;
00410
00411 long i, j ;
00412 for ( i=0 ; ( i<oline ) && ( i<block[olabel].rows_all ) ; i++ )
00413 {
00414 read_to_eoln( input[actual],buffer ) ;
00415 }
00416
00417 for ( i=0 ; i<oorder ; i++ )
00418 {
00419 read_string( input[actual],buffer ) ;
00420 }
00421 j=read_string( input[actual],ovalue ) ;
00422
00423 if ( j!=1 )
00424 {
00425 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
00426 read_error=1 ;
00427 }
00428 }
00429
00430
00431
00432
00433
00434
00435 void cmlfile::get_next_line_in_section ( long olabel, char *ovalue )
00436 {
00437 if ( !compiled )
00438 {
00439 compile() ;
00440 }
00441
00442 actual=block[olabel].file[0] ;
00443 fseek( input[actual],block[olabel].pos[0] + block[olabel].last_pos,SEEK_SET );
00444
00445
00446 do{
00447 read_to_eoln( input[actual],buffer ) ;
00448
00449 if(ftell(input[actual]) > block[olabel].end[0]){
00450 printf("Section %s has less data than requested, line %d, file %s\n", block[olabel].word, __LINE__, __FILE__);
00451 read_error=1;
00452 exit(0);
00453 }
00454
00455 }while(buffer[0] == '#' || buffer[0] == '\n' || buffer[0] == '\0');
00456
00457 strcpy(ovalue,buffer);
00458
00459 block[olabel].last_pos = ftell(input[actual]) - block[olabel].pos[0];
00460
00461
00462 }
00463
00464
00465
00466
00467
00468 void cmlfile::get_next_line_in_section ( long olabel, long &ovalue )
00469 {
00470 if ( !compiled )
00471 {
00472 compile() ;
00473 }
00474
00475 actual=block[olabel].file[0] ;
00476 fseek( input[actual],block[olabel].pos[0] + block[olabel].last_pos,SEEK_SET );
00477
00478
00479 do{
00480 read_to_eoln( input[actual],buffer ) ;
00481
00482 if(ftell(input[actual]) > block[olabel].end[0]){
00483 printf( "Section %s has less data than requested, line %d, file %s\n", block[olabel].word, __LINE__, __FILE__);
00484 read_error=1 ;
00485 exit(0);
00486 }
00487
00488 }while(buffer[0] == '#' || buffer[0] == '\n' || buffer[0] == '\0');
00489
00490 ovalue = atol(buffer);
00491
00492
00493 block[olabel].last_pos = ftell(input[actual]) - block[olabel].pos[0];
00494
00495 }
00496
00497
00498
00499
00500
00501
00502 void cmlfile::get_next_line_in_section ( long olabel, double &ovalue )
00503 {
00504 if ( !compiled )
00505 {
00506 compile() ;
00507 }
00508
00509 actual=block[olabel].file[0] ;
00510 fseek( input[actual],block[olabel].pos[0] + block[olabel].last_pos,SEEK_SET );
00511
00512
00513 do{
00514 read_to_eoln( input[actual],buffer ) ;
00515
00516 if(ftell(input[actual]) > block[olabel].end[0]){
00517 printf( "Section %s has less data than requested, line %d, file %s\n", block[olabel].word, __LINE__, __FILE__);
00518 read_error=1 ;
00519 exit(0);
00520 }
00521
00522 }while(buffer[0] == '#' || buffer[0] == '\n' || buffer[0] == '\0');
00523
00524 ovalue = atof(buffer);
00525
00526 block[olabel].last_pos = ftell(input[actual]) - block[olabel].pos[0];
00527
00528 }
00529
00530
00531 long cmlfile::name ( const char *obuffer )
00532 {
00533 long i ;
00534 for ( i=0 ; i<names ; i++ )
00535 {
00536 if ( str_equal( obuffer,get_name[i].word ))
00537 {
00538 return i ;
00539 }
00540 }
00541 return None ;
00542 }
00543
00544
00545 void cmlfile::open ( const char *ofname )
00546 {
00547 long i ;
00548 for ( i=0 ; i<files ; i++ )
00549 {
00550 fclose( input[i] ) ;
00551 }
00552 input[0]=fopen( ofname,"rt" ) ;
00553 if ( !input[0] )
00554 {
00555 printf( "Cannot open file %s.\n",ofname ) ;
00556 open_error=1 ;
00557 return ;
00558 }
00559 files=1 ;
00560 compiled=0 ;
00561 }
00562
00563 void cmlfile::open_for_output ( const char *ofname )
00564 {
00565 output=fopen( ofname,"wt" ) ;
00566 if ( !output )
00567 {
00568 printf( "For some reason cannot open file %s.\n",ofname ) ;
00569 open_error=1 ;
00570 }
00571 }
00572
00573 void cmlfile::close ( void )
00574 {
00575 long i ;
00576 for ( i=0 ; i<files ; i++ )
00577 {
00578 fclose( input[i] ) ;
00579 input[i]=NULL ;
00580 }
00581 files=0 ;
00582 if ( output )
00583 {
00584 fclose( output ) ;
00585 output=NULL ;
00586 }
00587 }
00588
00589 void cmlfile::set_labels ( long olabels )
00590 {
00591 labels=olabels ;
00592 stop=new keyword[olabels] ;
00593 compiled=0 ;
00594 }
00595 void cmlfile::set_sections ( long osections )
00596 {
00597 sections=osections ;
00598 block=new section[osections] ;
00599 compiled=0 ;
00600 }
00601
00602 void cmlfile::set_label_string ( long olabel , const char *olabel_string )
00603 {
00604 strcpy( stop[olabel].word,olabel_string ) ;
00605 compiled=0 ;
00606 }
00607
00608 void cmlfile::set_section_string ( long olabel , const char *osection_string )
00609 {
00610 strcpy( block[olabel].word,osection_string ) ;
00611 compiled=0 ;
00612 }
00613
00614 void cmlfile::set_double_format ( const char *odouble_format )
00615 {
00616 strcpy( double_format,odouble_format ) ;
00617 }
00618
00619 void cmlfile::compile ( void )
00620 {
00621 requirement_insufficient=0 ;
00622 if ( !input[0] )
00623 {
00624 printf( "Nothing to compile.\n" ) ;
00625 return ;
00626 }
00627 long i,j ;
00628
00629 actual=0 ;
00630
00631 do
00632 {
00633 while ( !feof( input[actual] ))
00634 {
00635 fscanf( input[actual],"%s",buffer ) ;
00636 j=label( buffer ) ;
00637 switch ( j )
00638 {
00639 case None:
00640 break ;
00641 case Comment:
00642 break ;
00643 case File:
00644 fscanf( input[actual],"%s",buffer ) ;
00645 open_next_input( buffer ) ;
00646 break ;
00647 case Section:
00648 stat_section() ;
00649 break ;
00650 case EndSection:
00651 break ;
00652 default:
00653 stop[j].n++ ;
00654 break ;
00655 }
00656 }
00657 actual++ ;
00658 }
00659 while ( input[actual] ) ;
00660
00661 for ( i=0 ; i<labels ; i++ )
00662 {
00663 stop[i].file=new long[stop[i].n] ;
00664 stop[i].position=new long[stop[i].n] ;
00665 }
00666
00667 for ( actual=0 ; actual<files ; actual++ )
00668 {
00669 rewind( input[actual] ) ;
00670 while ( !feof( input[actual] ))
00671 {
00672 fscanf( input[actual],"%s",buffer ) ;
00673 j=label( buffer ) ;
00674 switch ( j )
00675 {
00676 case None:
00677 break ;
00678 case Comment:
00679 break ;
00680 case File:
00681 read_to_eoln( input[actual],buffer ) ;
00682 break ;
00683 case Section:
00684 jump_over_section() ;
00685 break ;
00686 case EndSection:
00687 break ;
00688 default:
00689 stop[j].file[stop[j].i]=actual ;
00690 stop[j].position[stop[j].i]=ftell( input[actual] ) ;
00691 stop[j].i++ ;
00692 break ;
00693 }
00694 }
00695 }
00696 compiled=1 ;
00697 }
00698
00699 void cmlfile::check_requirements ( void )
00700 {
00701 if ( !compiled )
00702 {
00703 compile() ;
00704 }
00705 long i ;
00706 for ( i=0 ; i<labels ; i++ )
00707 {
00708 if ( stop[i].n<stop[i].req )
00709 {
00710 printf( "Insufficient input for label %s. This means fatal error.\n",stop[i].word ) ;
00711 requirement_insufficient=1 ;
00712 }
00713 }
00714 for ( i=0 ; i<sections ; i++ )
00715 {
00716 if ( block[i].rows_all<block[i].req )
00717 {
00718 printf( "Insufficient input for section %s. This means fatal error.\n",block[i].word ) ;
00719 requirement_insufficient=1 ;
00720 }
00721 }
00722 }
00723
00724 void cmlfile::require ( long olabel )
00725 {
00726 stop[olabel].req=Required ;
00727 }
00728
00729 void cmlfile::minimal ( long olabel , long ominimal )
00730 {
00731 stop[olabel].req=ominimal ;
00732 }
00733
00734 void cmlfile::optionalize ( long olabel )
00735 {
00736 stop[olabel].req=Optional ;
00737 }
00738
00739 void cmlfile::refuse ( long olabel )
00740 {
00741 stop[olabel].req=Refused ;
00742 }
00743
00744 void cmlfile::check_label ( long olabel )
00745 {
00746 if ( !compiled )
00747 {
00748 compile() ;
00749 }
00750 if ( stop[olabel].n<stop[olabel].req )
00751 {
00752 printf( "Insufficient input for label %s. This means fatal error.\n",stop[olabel].word ) ;
00753 requirement_insufficient=1 ;
00754 }
00755 }
00756
00757 void cmlfile::set_minimal_rows ( long osection , long ominimal )
00758 {
00759 block[osection].req=ominimal ;
00760 }
00761
00762 void cmlfile::check_section ( long osection )
00763 {
00764 if ( !compiled )
00765 {
00766 compile() ;
00767 }
00768 if ( block[osection].rows_all<block[osection].req )
00769 {
00770 printf( "Insufficient input for section %s. This means fatal error.\n",block[osection].word ) ;
00771 requirement_insufficient=1 ;
00772 }
00773 }
00774
00775 void cmlfile::load_labels ( const char *orcname )
00776 {
00777 FILE *rc ;
00778 rc=fopen( orcname,"rt" ) ;
00779 if ( !rc )
00780 {
00781 printf( "Cannot open rc file %s.\n",orcname ) ;
00782 open_error=1 ;
00783 return ;
00784 }
00785 long j,l=0,s=0 ;
00786 while ( !feof( rc ))
00787 {
00788 fscanf( rc,"%s",buffer ) ;
00789 if ( str_equal( KeywordSection,buffer ))
00790 {
00791 s++ ;
00792 read_to_eoln( rc,buffer ) ;
00793 }
00794 else
00795 {
00796 if (( buffer[0]>='A' ) && ( buffer[0]<='z' ))
00797 {
00798 l++ ;
00799 read_to_eoln( rc,buffer ) ;
00800 }
00801 }
00802 }
00803 rewind( rc ) ;
00804 set_labels( l ) ;
00805 set_sections( s ) ;
00806
00807 l=0 ; s=0 ;
00808
00809 while ( !feof( rc ))
00810 {
00811 j=fscanf( rc,"%s",buffer ) ;
00812 if ( j!=1 )
00813 {
00814 break ;
00815 }
00816 if ( str_equal( KeywordSection,buffer ))
00817 {
00818 fscanf( rc,"%s",buffer ) ;
00819 fscanf( rc,"%ld",&j ) ;
00820 set_section_string( s,buffer ) ;
00821 set_minimal_rows( s,j ) ;
00822 s++ ;
00823 }
00824 else
00825 {
00826 if (( buffer[0]>='A' ) && ( buffer[0]<='z' ))
00827 {
00828 fscanf( rc,"%ld",&j ) ;
00829 set_label_string( l,buffer ) ;
00830 minimal( l,j ) ;
00831 l++ ;
00832 }
00833 }
00834 }
00835 compiled=0 ;
00836 }
00837
00838 void cmlfile::inherit_labels ( cmlfile &of )
00839 {
00840 if ( stop )
00841 {
00842 delete [] stop ;
00843 }
00844 if ( block )
00845 {
00846 delete [] block ;
00847 }
00848 labels=of.labels ;
00849 sections=of.sections ;
00850
00851 stop=new keyword[labels] ;
00852 block=new section[sections] ;
00853
00854 long i ;
00855 for ( i=0 ; i<labels ; i++ )
00856 {
00857 stop[i].copy( of.stop[i] ) ;
00858 }
00859 for ( i=0 ; i<sections ; i++ )
00860 {
00861 block[i].copy( of.block[i] ) ;
00862 }
00863 compiled=0 ;
00864 }
00865
00866 void cmlfile::get_value_count ( long olabel , long &ocount )
00867 {
00868 if ( !compiled )
00869 {
00870 compile() ;
00871 }
00872 ocount=stop[olabel].n ;
00873 }
00874
00875 void cmlfile::get_value ( long olabel , long &ovalue )
00876 {
00877 if ( !compiled )
00878 {
00879 compile() ;
00880 }
00881 if ( !stop[olabel].n )
00882 {
00883 ovalue=NoInt ;
00884 return ;
00885 }
00886 if ( normal_read_disable )
00887 {
00888 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
00889 ovalue=NoInt ;
00890 read_error=1 ;
00891 return ;
00892 }
00893 actual=stop[olabel].file[0] ;
00894 fseek( input[actual],stop[olabel].position[0],SEEK_SET ) ;
00895 long j ;
00896 j=fscanf( input[actual],"%ld",&ovalue ) ;
00897
00898 if ( j!=1 )
00899 {
00900 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
00901 read_error=1 ;
00902 }
00903 }
00904
00905 void cmlfile::get_value ( long olabel , double &ovalue )
00906 {
00907 if ( !compiled )
00908 {
00909 compile() ;
00910 }
00911 if ( !stop[olabel].n )
00912 {
00913 ovalue=NoDouble ;
00914 return ;
00915 }
00916 if ( normal_read_disable )
00917 {
00918 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
00919 ovalue=NoDouble ;
00920 read_error=1 ;
00921 return ;
00922 }
00923 actual=stop[olabel].file[0] ;
00924 fseek( input[actual],stop[olabel].position[0],SEEK_SET ) ;
00925 long j ;
00926 j=fscanf( input[actual],"%lf",&ovalue ) ;
00927
00928 if ( j!=1 )
00929 {
00930 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
00931 read_error=1 ;
00932 }
00933 }
00934
00935 void cmlfile::get_value ( long olabel , char *ovalue )
00936 {
00937 if ( !compiled )
00938 {
00939 compile() ;
00940 }
00941 if ( !stop[olabel].n )
00942 {
00943 ovalue[0]=0 ;
00944 return ;
00945 }
00946 if ( normal_read_disable )
00947 {
00948 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
00949 ovalue[0]=0 ;
00950 read_error=1 ;
00951 return ;
00952 }
00953 actual=stop[olabel].file[0] ;
00954 fseek( input[actual],stop[olabel].position[0],SEEK_SET ) ;
00955 long j ;
00956 j=read_string( input[actual],ovalue ) ;
00957
00958 if ( j!=1 )
00959 {
00960 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
00961 read_error=1 ;
00962 }
00963 }
00964
00965 void cmlfile::get_value ( long olabel , long oorder , long &ovalue )
00966 {
00967 if ( !compiled )
00968 {
00969 compile() ;
00970 }
00971 if ( !stop[olabel].n )
00972 {
00973 ovalue=NoInt ;
00974 return ;
00975 }
00976 if ( normal_read_disable )
00977 {
00978 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
00979 ovalue=NoInt ;
00980 read_error=1 ;
00981 return ;
00982 }
00983 actual=stop[olabel].file[0] ;
00984 fseek( input[actual],stop[olabel].position[0],SEEK_SET ) ;
00985 long i,j ;
00986 for ( i=0 ; i<oorder ; i++ )
00987 {
00988 read_string( input[actual],buffer ) ;
00989 }
00990 j=fscanf( input[actual],"%ld",&ovalue ) ;
00991
00992 if ( j!=1 )
00993 {
00994 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
00995 read_error=1 ;
00996 }
00997 }
00998
00999 void cmlfile::get_value ( long olabel , long oorder , double &ovalue )
01000 {
01001 if ( !compiled )
01002 {
01003 compile() ;
01004 }
01005 if ( !stop[olabel].n )
01006 {
01007 ovalue=NoDouble ;
01008 return ;
01009 }
01010 if ( normal_read_disable )
01011 {
01012 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01013 ovalue=NoDouble ;
01014 read_error=1 ;
01015 return ;
01016 }
01017 actual=stop[olabel].file[0] ;
01018 fseek( input[actual],stop[olabel].position[0],SEEK_SET ) ;
01019 long i,j ;
01020 for ( i=0 ; i<oorder ; i++ )
01021 {
01022 read_string( input[actual],buffer ) ;
01023 }
01024 j=fscanf( input[actual],"%lf",&ovalue ) ;
01025
01026 if ( j!=1 )
01027 {
01028 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01029 read_error=1 ;
01030 }
01031 }
01032
01033 void cmlfile::get_value ( long olabel , long oorder , char *ovalue )
01034 {
01035 if ( !compiled )
01036 {
01037 compile() ;
01038 }
01039 if ( !stop[olabel].n )
01040 {
01041 ovalue[0]=0 ;
01042 return ;
01043 }
01044 if ( normal_read_disable )
01045 {
01046 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01047 ovalue[0]=0 ;
01048 read_error=1 ;
01049 return ;
01050 }
01051 actual=stop[olabel].file[0] ;
01052 fseek( input[actual],stop[olabel].position[0],SEEK_SET ) ;
01053 long i,j ;
01054 for ( i=0 ; i<oorder ; i++ )
01055 {
01056 read_string( input[actual],ovalue ) ;
01057 }
01058 j=read_string( input[actual],ovalue ) ;
01059
01060 if ( j!=1 )
01061 {
01062 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01063 read_error=1 ;
01064 }
01065 }
01066
01067 void cmlfile::get_value_with_key ( long olabel , long okey , long &ovalue )
01068 {
01069 if ( !compiled )
01070 {
01071 compile() ;
01072 }
01073 if ( !stop[olabel].n )
01074 {
01075 ovalue=NoInt ;
01076 return ;
01077 }
01078 if ( normal_read_disable )
01079 {
01080 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01081 ovalue=NoInt ;
01082 read_error=1 ;
01083 return ;
01084 }
01085 long i=0,pos,key ;
01086 do
01087 {
01088 actual=stop[olabel].file[i] ;
01089 pos=stop[olabel].position[i] ;
01090 fseek( input[actual],pos,SEEK_SET ) ;
01091 fscanf( input[actual],"%ld",&key ) ;
01092 if ( key!=okey )
01093 {
01094 i++ ;
01095 }
01096 }
01097 while (( key!=okey ) && ( i<stop[olabel].n )) ;
01098 if ( i==stop[olabel].n )
01099 {
01100 printf( "Key value %ld does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01101 ovalue=NoInt ;
01102 return ;
01103 }
01104 long j ;
01105 j=fscanf( input[actual],"%ld",&ovalue ) ;
01106
01107 if ( j!=1 )
01108 {
01109 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01110 read_error=1 ;
01111 }
01112 }
01113
01114 void cmlfile::get_value_with_key ( long olabel , long okey , double &ovalue )
01115 {
01116 if ( !compiled )
01117 {
01118 compile() ;
01119 }
01120 if ( !stop[olabel].n )
01121 {
01122 ovalue=NoDouble ;
01123 return ;
01124 }
01125 if ( normal_read_disable )
01126 {
01127 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01128 ovalue=NoDouble ;
01129 read_error=1 ;
01130 return ;
01131 }
01132 long i=0,pos,key ;
01133 do
01134 {
01135 actual=stop[olabel].file[i] ;
01136 pos=stop[olabel].position[i] ;
01137 fseek( input[actual],pos,SEEK_SET ) ;
01138 fscanf( input[actual],"%ld",&key ) ;
01139 if ( key!=okey )
01140 {
01141 i++ ;
01142 }
01143 }
01144 while (( key!=okey ) && ( i<stop[olabel].n )) ;
01145 if ( i==stop[olabel].n )
01146 {
01147 printf( "Key value %ld does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01148 ovalue=NoDouble ;
01149 return ;
01150 }
01151 long j ;
01152 j=fscanf( input[actual],"%lf",&ovalue ) ;
01153
01154 if ( j!=1 )
01155 {
01156 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01157 read_error=1 ;
01158 }
01159 }
01160
01161 void cmlfile::get_value_with_key ( long olabel , long okey , char *ovalue )
01162 {
01163 if ( !compiled )
01164 {
01165 compile() ;
01166 }
01167 if ( !stop[olabel].n )
01168 {
01169 ovalue[0]=0 ;
01170 return ;
01171 }
01172 if ( normal_read_disable )
01173 {
01174 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01175 ovalue[0]=0 ;
01176 read_error=1 ;
01177 return ;
01178 }
01179 long i=0,pos,key ;
01180 do
01181 {
01182 actual=stop[olabel].file[i] ;
01183 pos=stop[olabel].position[i] ;
01184 fseek( input[actual],pos,SEEK_SET ) ;
01185 fscanf( input[actual],"%ld",&key ) ;
01186 if ( key!=okey )
01187 {
01188 i++ ;
01189 }
01190 }
01191 while (( key!=okey ) && ( i<stop[olabel].n )) ;
01192 if ( i==stop[olabel].n )
01193 {
01194 printf( "Key value %ld does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01195 ovalue[0]=0 ;
01196 return ;
01197 }
01198 long j ;
01199 j=read_string( input[actual],ovalue ) ;
01200
01201 if ( j!=1 )
01202 {
01203 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01204 read_error=1 ;
01205 }
01206 }
01207
01208 void cmlfile::get_value_with_key ( long olabel , long okey , long oorder , long &ovalue )
01209 {
01210 if ( !compiled )
01211 {
01212 compile() ;
01213 }
01214 if ( !stop[olabel].n )
01215 {
01216 ovalue=NoInt ;
01217 return ;
01218 }
01219 if ( normal_read_disable )
01220 {
01221 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01222 ovalue=NoInt ;
01223 read_error=1 ;
01224 return ;
01225 }
01226 long i=0,pos,key ;
01227 do
01228 {
01229 actual=stop[olabel].file[i] ;
01230 pos=stop[olabel].position[i] ;
01231 fseek( input[actual],pos,SEEK_SET ) ;
01232 fscanf( input[actual],"%ld",&key ) ;
01233 if ( key!=okey )
01234 {
01235 i++ ;
01236 }
01237 }
01238 while (( key!=okey ) && ( i<stop[olabel].n )) ;
01239 if ( i==stop[olabel].n )
01240 {
01241 printf( "Key value %ld does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01242 ovalue=NoInt ;
01243 return ;
01244 }
01245 long j ;
01246 for ( i=0 ; i<oorder ; i++ )
01247 {
01248 read_string( input[actual],buffer ) ;
01249 }
01250 j=fscanf( input[actual],"%ld",&ovalue ) ;
01251
01252 if ( j!=1 )
01253 {
01254 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01255 read_error=1 ;
01256 }
01257 }
01258
01259 void cmlfile::get_value_with_key ( long olabel , long okey , long oorder , double &ovalue )
01260 {
01261 if ( !compiled )
01262 {
01263 compile() ;
01264 }
01265 if ( !stop[olabel].n )
01266 {
01267 ovalue=NoDouble ;
01268 return ;
01269 }
01270 if ( normal_read_disable )
01271 {
01272 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01273 ovalue=NoDouble ;
01274 read_error=1 ;
01275 return ;
01276 }
01277 long i=0,pos,key ;
01278 do
01279 {
01280 actual=stop[olabel].file[i] ;
01281 pos=stop[olabel].position[i] ;
01282 fseek( input[actual],pos,SEEK_SET ) ;
01283 fscanf( input[actual],"%ld",&key ) ;
01284 if ( key!=okey )
01285 {
01286 i++ ;
01287 }
01288 }
01289 while (( key!=okey ) && ( i<stop[olabel].n )) ;
01290 if ( i==stop[olabel].n )
01291 {
01292 printf( "Key value %ld does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01293 ovalue=NoDouble ;
01294 return ;
01295 }
01296 for ( i=0 ; i<oorder ; i++ )
01297 {
01298 read_string( input[actual],buffer ) ;
01299 }
01300 long j ;
01301 j=fscanf( input[actual],"%lf",&ovalue ) ;
01302
01303 if ( j!=1 )
01304 {
01305 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01306 read_error=1 ;
01307 }
01308 }
01309
01310 void cmlfile::get_value_with_key ( long olabel , long okey , long oorder , char *ovalue )
01311 {
01312 if ( !compiled )
01313 {
01314 compile() ;
01315 }
01316 if ( !stop[olabel].n )
01317 {
01318 ovalue[0]=0 ;
01319 return ;
01320 }
01321 if ( normal_read_disable )
01322 {
01323 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01324 ovalue[0]=0 ;
01325 read_error=1 ;
01326 return ;
01327 }
01328 long i=0,pos,key ;
01329 do
01330 {
01331 actual=stop[olabel].file[i] ;
01332 pos=stop[olabel].position[i] ;
01333 fseek( input[actual],pos,SEEK_SET ) ;
01334 fscanf( input[actual],"%ld",&key ) ;
01335 if ( key!=okey )
01336 {
01337 i++ ;
01338 }
01339 }
01340 while (( key!=okey ) && ( i<stop[olabel].n )) ;
01341 if ( i==stop[olabel].n )
01342 {
01343 printf( "Key value %ld does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01344 ovalue[0]=0 ;
01345 return ;
01346 }
01347 for ( i=0 ; i<oorder ; i++ )
01348 {
01349 read_string( input[actual],ovalue ) ;
01350 }
01351 long j ;
01352 j=read_string( input[actual],ovalue ) ;
01353
01354 if ( j!=1 )
01355 {
01356 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01357 read_error=1 ;
01358 }
01359 }
01360
01361 void cmlfile::get_value_with_key ( long olabel , const char *okey , long &ovalue )
01362 {
01363 if ( !compiled )
01364 {
01365 compile() ;
01366 }
01367 if ( !stop[olabel].n )
01368 {
01369 ovalue=NoInt ;
01370 return ;
01371 }
01372 if ( normal_read_disable )
01373 {
01374 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01375 ovalue=NoInt ;
01376 read_error=1 ;
01377 return ;
01378 }
01379 long i=0,pos ;
01380 do
01381 {
01382 actual=stop[olabel].file[i] ;
01383 pos=stop[olabel].position[i] ;
01384 fseek( input[actual],pos,SEEK_SET ) ;
01385 read_string( input[actual],buffer ) ;
01386 if ( !str_equal( okey,buffer ))
01387 {
01388 i++ ;
01389 }
01390 }
01391 while (( !str_equal( okey,buffer )) && ( i<stop[olabel].n )) ;
01392 if ( i==stop[olabel].n )
01393 {
01394 printf( "Key value %s does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01395 ovalue=NoInt ;
01396 return ;
01397 }
01398 long j ;
01399 j=fscanf( input[actual],"%ld",&ovalue ) ;
01400
01401 if ( j!=1 )
01402 {
01403 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01404 read_error=1 ;
01405 }
01406 }
01407
01408 void cmlfile::get_value_with_key ( long olabel , const char *okey , double &ovalue )
01409 {
01410 if ( !compiled )
01411 {
01412 compile() ;
01413 }
01414 if ( !stop[olabel].n )
01415 {
01416 ovalue=NoDouble ;
01417 return ;
01418 }
01419 if ( normal_read_disable )
01420 {
01421 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01422 ovalue=NoDouble ;
01423 read_error=1 ;
01424 return ;
01425 }
01426 long i=0,pos ;
01427 do
01428 {
01429 actual=stop[olabel].file[i] ;
01430 pos=stop[olabel].position[i] ;
01431 fseek( input[actual],pos,SEEK_SET ) ;
01432 read_string( input[actual],buffer ) ;
01433 if ( !str_equal( okey,buffer ))
01434 {
01435 i++ ;
01436 }
01437 }
01438 while (( !str_equal( okey,buffer )) && ( i<stop[olabel].n )) ;
01439 if ( i==stop[olabel].n )
01440 {
01441 printf( "Key value %s does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01442 ovalue=NoDouble ;
01443 return ;
01444 }
01445 long j ;
01446 j=fscanf( input[actual],"%lf",&ovalue ) ;
01447
01448 if ( j!=1 )
01449 {
01450 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01451 read_error=1 ;
01452 }
01453 }
01454
01455 void cmlfile::get_value_with_key ( long olabel , const char *okey , char *ovalue )
01456 {
01457 if ( !compiled )
01458 {
01459 compile() ;
01460 }
01461 if ( !stop[olabel].n )
01462 {
01463 ovalue[0]=0 ;
01464 return ;
01465 }
01466 if ( normal_read_disable )
01467 {
01468 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01469 ovalue[0]=0 ;
01470 read_error=1 ;
01471 return ;
01472 }
01473 long i=0,pos ;
01474 do
01475 {
01476 actual=stop[olabel].file[i] ;
01477 pos=stop[olabel].position[i] ;
01478 fseek( input[actual],pos,SEEK_SET ) ;
01479 read_string( input[actual],buffer ) ;
01480 if ( !str_equal( okey,buffer ))
01481 {
01482 i++ ;
01483 }
01484 }
01485 while (( !str_equal( okey,buffer )) && ( i<stop[olabel].n )) ;
01486 if ( i==stop[olabel].n )
01487 {
01488 printf( "Key value %s does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01489 ovalue[0]=0 ;
01490 return ;
01491 }
01492 long j ;
01493 j=read_string( input[actual],ovalue ) ;
01494
01495 if ( j!=1 )
01496 {
01497 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01498 read_error=1 ;
01499 }
01500 }
01501
01502 void cmlfile::get_value_with_key ( long olabel , const char *okey , long oorder , long &ovalue )
01503 {
01504 if ( !compiled )
01505 {
01506 compile() ;
01507 }
01508 if ( !stop[olabel].n )
01509 {
01510 ovalue=NoInt ;
01511 return ;
01512 }
01513 if ( normal_read_disable )
01514 {
01515 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01516 ovalue=NoInt ;
01517 read_error=1 ;
01518 return ;
01519 }
01520 long i=0,pos ;
01521 do
01522 {
01523 actual=stop[olabel].file[i] ;
01524 pos=stop[olabel].position[i] ;
01525 fseek( input[actual],pos,SEEK_SET ) ;
01526 read_string( input[actual],buffer ) ;
01527 if ( !str_equal( okey,buffer ))
01528 {
01529 i++ ;
01530 }
01531 }
01532 while (( !str_equal( okey,buffer )) && ( i<stop[olabel].n )) ;
01533 if ( i==stop[olabel].n )
01534 {
01535 printf( "Key value %s does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01536 ovalue=NoInt ;
01537 return ;
01538 }
01539 long j ;
01540 for ( i=0 ; i<oorder ; i++ )
01541 {
01542 read_string( input[actual],buffer ) ;
01543 }
01544 j=fscanf( input[actual],"%ld",&ovalue ) ;
01545
01546 if ( j!=1 )
01547 {
01548 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01549 read_error=1 ;
01550 }
01551 }
01552
01553 void cmlfile::get_value_with_key ( long olabel , const char *okey , long oorder , double &ovalue )
01554 {
01555 if ( !compiled )
01556 {
01557 compile() ;
01558 }
01559 if ( !stop[olabel].n )
01560 {
01561 ovalue=NoDouble ;
01562 return ;
01563 }
01564 if ( normal_read_disable )
01565 {
01566 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01567 ovalue=NoDouble ;
01568 read_error=1 ;
01569 return ;
01570 }
01571 long i=0,pos ;
01572 do
01573 {
01574 actual=stop[olabel].file[i] ;
01575 pos=stop[olabel].position[i] ;
01576 fseek( input[actual],pos,SEEK_SET ) ;
01577 read_string( input[actual],buffer ) ;
01578 if ( !str_equal( okey,buffer ))
01579 {
01580 i++ ;
01581 }
01582 }
01583 while (( !str_equal( okey,buffer )) && ( i<stop[olabel].n )) ;
01584 if ( i==stop[olabel].n )
01585 {
01586 printf( "Key value %s does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01587 ovalue=NoDouble ;
01588 return ;
01589 }
01590 for ( i=0 ; i<oorder ; i++ )
01591 {
01592 read_string( input[actual],buffer ) ;
01593 }
01594 long j ;
01595 j=fscanf( input[actual],"%lf",&ovalue ) ;
01596
01597 if ( j!=1 )
01598 {
01599 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01600 read_error=1 ;
01601 }
01602 }
01603
01604 void cmlfile::get_value_with_key ( long olabel , const char *okey , long oorder , char *ovalue )
01605 {
01606 if ( !compiled )
01607 {
01608 compile() ;
01609 }
01610 if ( !stop[olabel].n )
01611 {
01612 ovalue[0]=0 ;
01613 return ;
01614 }
01615 if ( normal_read_disable )
01616 {
01617 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01618 ovalue[0]=0 ;
01619 read_error=1 ;
01620 return ;
01621 }
01622 long i=0,pos ;
01623 do
01624 {
01625 actual=stop[olabel].file[i] ;
01626 pos=stop[olabel].position[i] ;
01627 fseek( input[actual],pos,SEEK_SET ) ;
01628 read_string( input[actual],buffer ) ;
01629 if ( !str_equal( okey,buffer ))
01630 {
01631 i++ ;
01632 }
01633 }
01634 while (( !str_equal( okey,buffer )) && ( i<stop[olabel].n )) ;
01635 if ( i==stop[olabel].n )
01636 {
01637 printf( "Key value %s does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
01638 ovalue[0]=0 ;
01639 return ;
01640 }
01641 for ( i=0 ; i<oorder ; i++ )
01642 {
01643 read_string( input[actual],ovalue ) ;
01644 }
01645 long j ;
01646 j=read_string( input[actual],ovalue ) ;
01647
01648 if ( j!=1 )
01649 {
01650 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01651 read_error=1 ;
01652 }
01653 }
01654
01655 void cmlfile::get_value_with_index ( long olabel , long oindex , long &ovalue )
01656 {
01657 if ( !compiled )
01658 {
01659 compile() ;
01660 }
01661 if ( !stop[olabel].n )
01662 {
01663 ovalue=NoInt ;
01664 return ;
01665 }
01666 if ( normal_read_disable )
01667 {
01668 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01669 ovalue=NoInt ;
01670 read_error=1 ;
01671 return ;
01672 }
01673 if ( oindex>=stop[olabel].n )
01674 {
01675 printf( "Index over possible value.\n" ) ;
01676 ovalue=NoInt ;
01677 read_error=1 ;
01678 return ;
01679 }
01680
01681 actual=stop[olabel].file[oindex] ;
01682 fseek( input[actual],stop[olabel].position[oindex],SEEK_SET ) ;
01683
01684 long j ;
01685 j=fscanf( input[actual],"%ld",&ovalue ) ;
01686
01687 if ( j!=1 )
01688 {
01689 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01690 read_error=1 ;
01691 }
01692 }
01693
01694 void cmlfile::get_value_with_index ( long olabel , long oindex , double &ovalue )
01695 {
01696 if ( !compiled )
01697 {
01698 compile() ;
01699 }
01700 if ( !stop[olabel].n )
01701 {
01702 ovalue=NoDouble ;
01703 return ;
01704 }
01705 if ( normal_read_disable )
01706 {
01707 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01708 ovalue=NoDouble ;
01709 read_error=1 ;
01710 return ;
01711 }
01712 if ( oindex>=stop[olabel].n )
01713 {
01714 printf( "Index over possible value.\n" ) ;
01715 ovalue=NoDouble ;
01716 read_error=1 ;
01717 return ;
01718 }
01719
01720 actual=stop[olabel].file[oindex] ;
01721 fseek( input[actual],stop[olabel].position[oindex],SEEK_SET ) ;
01722
01723 long j ;
01724 j=fscanf( input[actual],"%lf",&ovalue ) ;
01725
01726 if ( j!=1 )
01727 {
01728 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01729 read_error=1 ;
01730 }
01731 }
01732
01733 void cmlfile::get_value_with_index ( long olabel , long oindex , char *ovalue )
01734 {
01735 if ( !compiled )
01736 {
01737 compile() ;
01738 }
01739 if ( !stop[olabel].n )
01740 {
01741 ovalue[0]=0 ;
01742 return ;
01743 }
01744 if ( normal_read_disable )
01745 {
01746 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01747 ovalue[0]=0 ;
01748 read_error=1 ;
01749 return ;
01750 }
01751 if ( oindex>=stop[olabel].n )
01752 {
01753 printf( "Index over possible value.\n" ) ;
01754 ovalue[0]=0 ;
01755 read_error=1 ;
01756 return ;
01757 }
01758
01759 actual=stop[olabel].file[oindex] ;
01760 fseek( input[actual],stop[olabel].position[oindex],SEEK_SET ) ;
01761
01762 long j ;
01763 j=read_string( input[actual],ovalue ) ;
01764
01765 if ( j!=1 )
01766 {
01767 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01768 read_error=1 ;
01769 }
01770 }
01771
01772 void cmlfile::get_value_with_index ( long olabel , long oindex , long oorder , long &ovalue )
01773 {
01774 if ( !compiled )
01775 {
01776 compile() ;
01777 }
01778 if ( !stop[olabel].n )
01779 {
01780 ovalue=NoInt ;
01781 return ;
01782 }
01783 if ( normal_read_disable )
01784 {
01785 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01786 ovalue=NoInt ;
01787 read_error=1 ;
01788 return ;
01789 }
01790 if ( oindex>=stop[olabel].n )
01791 {
01792 printf( "Index over possible value.\n" ) ;
01793 ovalue=NoInt ;
01794 read_error=1 ;
01795 return ;
01796 }
01797
01798 actual=stop[olabel].file[oindex] ;
01799 fseek( input[actual],stop[olabel].position[oindex],SEEK_SET ) ;
01800
01801 long i,j ;
01802 for ( i=0 ; i<oorder ; i++ )
01803 {
01804 read_string( input[actual],buffer ) ;
01805 }
01806 j=fscanf( input[actual],"%ld",&ovalue ) ;
01807
01808 if ( j!=1 )
01809 {
01810 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01811 read_error=1 ;
01812 }
01813 }
01814
01815 void cmlfile::get_value_with_index ( long olabel , long oindex , long oorder , double &ovalue )
01816 {
01817 if ( !compiled )
01818 {
01819 compile() ;
01820 }
01821 if ( !stop[olabel].n )
01822 {
01823 ovalue=NoDouble ;
01824 return ;
01825 }
01826 if ( normal_read_disable )
01827 {
01828 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01829 ovalue=NoDouble ;
01830 read_error=1 ;
01831 return ;
01832 }
01833 if ( oindex>=stop[olabel].n )
01834 {
01835 printf( "Index over possible value.\n" ) ;
01836 ovalue=NoDouble ;
01837 read_error=1 ;
01838 return ;
01839 }
01840
01841 actual=stop[olabel].file[oindex] ;
01842 fseek( input[actual],stop[olabel].position[oindex],SEEK_SET ) ;
01843
01844 long i,j ;
01845 for ( i=0 ; i<oorder ; i++ )
01846 {
01847 read_string( input[actual],buffer ) ;
01848 }
01849 j=fscanf( input[actual],"%lf",&ovalue ) ;
01850
01851 if ( j!=1 )
01852 {
01853 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01854 read_error=1 ;
01855 }
01856 }
01857
01858 void cmlfile::get_value_with_index ( long olabel , long oindex , long oorder , char *ovalue )
01859 {
01860 if ( !compiled )
01861 {
01862 compile() ;
01863 }
01864 if ( !stop[olabel].n )
01865 {
01866 ovalue[0]=0 ;
01867 return ;
01868 }
01869 if ( normal_read_disable )
01870 {
01871 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01872 ovalue[0]=0 ;
01873 read_error=1 ;
01874 return ;
01875 }
01876 if ( oindex>=stop[olabel].n )
01877 {
01878 printf( "Index over possible value.\n" ) ;
01879 ovalue[0]=0 ;
01880 read_error=1 ;
01881 return ;
01882 }
01883
01884 actual=stop[olabel].file[oindex] ;
01885 fseek( input[actual],stop[olabel].position[oindex],SEEK_SET ) ;
01886
01887 long i,j ;
01888 for ( i=0 ; i<oorder ; i++ )
01889 {
01890 read_string( input[actual],ovalue ) ;
01891 }
01892 j=read_string( input[actual],ovalue ) ;
01893
01894 if ( j!=1 )
01895 {
01896 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01897 read_error=1 ;
01898 }
01899 }
01900
01901 void cmlfile::get_percentage ( long olabel , double &ovalue )
01902 {
01903 if ( !compiled )
01904 {
01905 compile() ;
01906 }
01907 if ( !stop[olabel].n )
01908 {
01909 ovalue=NoDouble ;
01910 return ;
01911 }
01912 if ( normal_read_disable )
01913 {
01914 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01915 read_error=1 ;
01916 return ;
01917 }
01918 actual=stop[olabel].file[0] ;
01919 fseek( input[actual],stop[olabel].position[0],SEEK_SET ) ;
01920 long j ;
01921 j=fscanf( input[actual],"%s",buffer ) ;
01922
01923 if ( j!=1 )
01924 {
01925 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01926 read_error=1 ;
01927 }
01928 sscanf( buffer,"%lf",&ovalue ) ;
01929 j=0 ;
01930 while ( buffer[j] )
01931 {
01932 if ( buffer[j]=='%' )
01933 {
01934 ovalue/=100.0 ;
01935 return ;
01936 }
01937 j++ ;
01938 }
01939 }
01940
01941 void cmlfile::get_percentage ( long olabel , long oorder , double &ovalue )
01942 {
01943 if ( !compiled )
01944 {
01945 compile() ;
01946 }
01947 if ( !stop[olabel].n )
01948 {
01949 ovalue=NoDouble ;
01950 return ;
01951 }
01952 if ( normal_read_disable )
01953 {
01954 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
01955 ovalue=NoDouble ;
01956 read_error=1 ;
01957 return ;
01958 }
01959 actual=stop[olabel].file[0] ;
01960 fseek( input[actual],stop[olabel].position[0],SEEK_SET ) ;
01961 long i,j ;
01962 for ( i=0 ; i<oorder ; i++ )
01963 {
01964 read_string( input[actual],buffer ) ;
01965 }
01966 j=fscanf( input[actual],"%s",buffer ) ;
01967
01968 if ( j!=1 )
01969 {
01970 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
01971 read_error=1 ;
01972 }
01973 sscanf( buffer,"%lf",&ovalue ) ;
01974 j=0 ;
01975 while ( buffer[j] )
01976 {
01977 if ( buffer[j]=='%' )
01978 {
01979 ovalue/=100.0 ;
01980 return ;
01981 }
01982 j++ ;
01983 }
01984 }
01985
01986 void cmlfile::get_percentage_with_key ( long olabel , long okey , double &ovalue )
01987 {
01988 if ( !compiled )
01989 {
01990 compile() ;
01991 }
01992 if ( !stop[olabel].n )
01993 {
01994 ovalue=NoDouble ;
01995 return ;
01996 }
01997 if ( normal_read_disable )
01998 {
01999 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02000 ovalue=NoDouble ;
02001 read_error=1 ;
02002 return ;
02003 }
02004 long i=0,pos,key ;
02005 do
02006 {
02007 actual=stop[olabel].file[i] ;
02008 pos=stop[olabel].position[i] ;
02009 fseek( input[actual],pos,SEEK_SET ) ;
02010 fscanf( input[actual],"%ld",&key ) ;
02011 if ( key!=okey )
02012 {
02013 i++ ;
02014 }
02015 }
02016 while (( key!=okey ) && ( i<stop[olabel].n )) ;
02017 if ( i==stop[olabel].n )
02018 {
02019 printf( "Key value %ld does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
02020 ovalue=NoDouble ;
02021 return ;
02022 }
02023 long j ;
02024 j=fscanf( input[actual],"%s",buffer ) ;
02025
02026 if ( j!=1 )
02027 {
02028 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02029 read_error=1 ;
02030 }
02031 sscanf( buffer,"%lf",&ovalue ) ;
02032 j=0 ;
02033 while ( buffer[j] )
02034 {
02035 if ( buffer[j]=='%' )
02036 {
02037 ovalue/=100.0 ;
02038 return ;
02039 }
02040 j++ ;
02041 }
02042 }
02043
02044 void cmlfile::get_percentage_with_key ( long olabel , long okey , long oorder , double &ovalue )
02045 {
02046 if ( !compiled )
02047 {
02048 compile() ;
02049 }
02050 if ( !stop[olabel].n )
02051 {
02052 ovalue=NoDouble ;
02053 return ;
02054 }
02055 if ( normal_read_disable )
02056 {
02057 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02058 ovalue=NoDouble ;
02059 read_error=1 ;
02060 return ;
02061 }
02062 long i=0,pos,key ;
02063 do
02064 {
02065 actual=stop[olabel].file[i] ;
02066 pos=stop[olabel].position[i] ;
02067 fseek( input[actual],pos,SEEK_SET ) ;
02068 fscanf( input[actual],"%ld",&key ) ;
02069 if ( key!=okey )
02070 {
02071 i++ ;
02072 }
02073 }
02074 while (( key!=okey ) && ( i<stop[olabel].n )) ;
02075 if ( i==stop[olabel].n )
02076 {
02077 printf( "Key value %ld does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
02078 ovalue=NoDouble ;
02079 return ;
02080 }
02081 for ( i=0 ; i<oorder ; i++ )
02082 {
02083 read_string( input[actual],buffer ) ;
02084 }
02085 long j ;
02086 j=fscanf( input[actual],"%s",buffer ) ;
02087
02088 if ( j!=1 )
02089 {
02090 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02091 read_error=1 ;
02092 }
02093 sscanf( buffer,"%lf",&ovalue ) ;
02094 j=0 ;
02095 while ( buffer[j] )
02096 {
02097 if ( buffer[j]=='%' )
02098 {
02099 ovalue/=100.0 ;
02100 return ;
02101 }
02102 j++ ;
02103 }
02104 }
02105
02106 void cmlfile::get_percentage_with_key ( long olabel , const char *okey , double &ovalue )
02107 {
02108 if ( !compiled )
02109 {
02110 compile() ;
02111 }
02112 if ( !stop[olabel].n )
02113 {
02114 ovalue=NoDouble ;
02115 return ;
02116 }
02117 if ( normal_read_disable )
02118 {
02119 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02120 ovalue=NoDouble ;
02121 read_error=1 ;
02122 return ;
02123 }
02124 long i=0,pos ;
02125 do
02126 {
02127 actual=stop[olabel].file[i] ;
02128 pos=stop[olabel].position[i] ;
02129 fseek( input[actual],pos,SEEK_SET ) ;
02130 fscanf( input[actual],"%s",buffer ) ;
02131 if ( !str_equal( okey,buffer ))
02132 {
02133 i++ ;
02134 }
02135 }
02136 while (( !str_equal( okey,buffer )) && ( i<stop[olabel].n )) ;
02137 if ( i==stop[olabel].n )
02138 {
02139 printf( "Key value %s does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
02140 ovalue=NoDouble ;
02141 }
02142 long j ;
02143 j=fscanf( input[actual],"%s",buffer ) ;
02144
02145 if ( j!=1 )
02146 {
02147 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02148 read_error=1 ;
02149 }
02150 sscanf( buffer,"%lf",&ovalue ) ;
02151 j=0 ;
02152 while ( buffer[j] )
02153 {
02154 if ( buffer[j]=='%' )
02155 {
02156 ovalue/=100.0 ;
02157 return ;
02158 }
02159 j++ ;
02160 }
02161 }
02162
02163 void cmlfile::get_percentage_with_key ( long olabel , const char *okey , long oorder , double &ovalue )
02164 {
02165 if ( !compiled )
02166 {
02167 compile() ;
02168 }
02169 if ( !stop[olabel].n )
02170 {
02171 ovalue=NoDouble ;
02172 return ;
02173 }
02174 if ( normal_read_disable )
02175 {
02176 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02177 ovalue=NoDouble ;
02178 read_error=1 ;
02179 return ;
02180 }
02181 long i=0,pos ;
02182 do
02183 {
02184 actual=stop[olabel].file[i] ;
02185 pos=stop[olabel].position[i] ;
02186 fseek( input[actual],pos,SEEK_SET ) ;
02187 fscanf( input[actual],"%s",buffer ) ;
02188 if ( !str_equal( okey,buffer ))
02189 {
02190 i++ ;
02191 }
02192 }
02193 while (( !str_equal( okey,buffer )) && ( i<stop[olabel].n )) ;
02194 if ( i==stop[olabel].n )
02195 {
02196 printf( "Key value %s does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
02197 ovalue=NoDouble ;
02198 }
02199 for ( i=0 ; i<oorder ; i++ )
02200 {
02201 read_string( input[actual],buffer ) ;
02202 }
02203 long j ;
02204 j=fscanf( input[actual],"%s",buffer ) ;
02205
02206 if ( j!=1 )
02207 {
02208 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02209 read_error=1 ;
02210 }
02211 sscanf( buffer,"%lf",&ovalue ) ;
02212 j=0 ;
02213 while ( buffer[j] )
02214 {
02215 if ( buffer[j]=='%' )
02216 {
02217 ovalue/=100.0 ;
02218 return ;
02219 }
02220 j++ ;
02221 }
02222 }
02223
02224 void cmlfile::get_percentage_with_index ( long olabel , long oindex , double &ovalue )
02225 {
02226 if ( !compiled )
02227 {
02228 compile() ;
02229 }
02230 if ( !stop[olabel].n )
02231 {
02232 ovalue=NoDouble ;
02233 return ;
02234 }
02235 if ( normal_read_disable )
02236 {
02237 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02238 ovalue=NoDouble ;
02239 read_error=1 ;
02240 return ;
02241 }
02242 if ( oindex>=stop[olabel].n )
02243 {
02244 printf( "Index over possible value.\n" ) ;
02245 ovalue=NoDouble ;
02246 read_error=1 ;
02247 return ;
02248 }
02249
02250 actual=stop[olabel].file[oindex] ;
02251 fseek( input[actual],stop[olabel].position[oindex],SEEK_SET ) ;
02252
02253 long j ;
02254 j=fscanf( input[actual],"%s",buffer ) ;
02255
02256 if ( j!=1 )
02257 {
02258 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02259 read_error=1 ;
02260 }
02261 sscanf( buffer,"%lf",&ovalue ) ;
02262 j=0 ;
02263 while ( buffer[j] )
02264 {
02265 if ( buffer[j]=='%' )
02266 {
02267 ovalue/=100.0 ;
02268 return ;
02269 }
02270 j++ ;
02271 }
02272 }
02273
02274 void cmlfile::get_percentage_with_index ( long olabel , long oindex , long oorder , double &ovalue )
02275 {
02276 if ( !compiled )
02277 {
02278 compile() ;
02279 }
02280 if ( !stop[olabel].n )
02281 {
02282 ovalue=NoDouble ;
02283 return ;
02284 }
02285 if ( normal_read_disable )
02286 {
02287 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02288 ovalue=NoDouble ;
02289 read_error=1 ;
02290 return ;
02291 }
02292 if ( oindex>=stop[olabel].n )
02293 {
02294 printf( "Index over possible value.\n" ) ;
02295 ovalue=NoDouble ;
02296 read_error=1 ;
02297 return ;
02298 }
02299
02300 actual=stop[olabel].file[oindex] ;
02301 fseek( input[actual],stop[olabel].position[oindex],SEEK_SET ) ;
02302
02303 long i,j ;
02304 for ( i=0 ; i<oorder ; i++ )
02305 {
02306 read_string( input[actual],buffer ) ;
02307 }
02308 j=fscanf( input[actual],"%s",buffer ) ;
02309
02310 if ( j!=1 )
02311 {
02312 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02313 read_error=1 ;
02314 }
02315 sscanf( buffer,"%lf",&ovalue ) ;
02316 j=0 ;
02317 while ( buffer[j] )
02318 {
02319 if ( buffer[j]=='%' )
02320 {
02321 ovalue/=100.0 ;
02322 return ;
02323 }
02324 j++ ;
02325 }
02326 }
02327
02328 void cmlfile::get_line ( long olabel , char *oline )
02329 {
02330 if ( !compiled )
02331 {
02332 compile() ;
02333 }
02334 if ( !stop[olabel].n )
02335 {
02336 oline[0]=0 ;
02337 return ;
02338 }
02339 if ( normal_read_disable )
02340 {
02341 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02342 oline[0]=0 ;
02343 read_error=1 ;
02344 return ;
02345 }
02346 actual=stop[olabel].file[0] ;
02347 fseek( input[actual],stop[olabel].position[0],SEEK_SET ) ;
02348 long j ;
02349 j=read_to_eoln( input[actual],oline ) ;
02350 if ( j==None )
02351 {
02352 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02353 read_error=1 ;
02354 }
02355 }
02356
02357 void cmlfile::get_line_with_key ( long olabel , long okey , char *oline )
02358 {
02359 if ( !compiled )
02360 {
02361 compile() ;
02362 }
02363 if ( !stop[olabel].n )
02364 {
02365 oline[0]=0 ;
02366 return ;
02367 }
02368 if ( normal_read_disable )
02369 {
02370 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02371 oline[0]=0 ;
02372 read_error=1 ;
02373 return ;
02374 }
02375 long i=0,pos,key ;
02376 do
02377 {
02378 actual=stop[olabel].file[i] ;
02379 pos=stop[olabel].position[i] ;
02380 fseek( input[actual],pos,SEEK_SET ) ;
02381 fscanf( input[actual],"%ld",&key ) ;
02382 if ( key!=okey )
02383 {
02384 i++ ;
02385 }
02386 }
02387 while (( key!=okey ) && ( i<stop[olabel].n )) ;
02388 if ( i==stop[olabel].n )
02389 {
02390 printf( "Key value %ld does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
02391 oline[0]=0 ;
02392 return ;
02393 }
02394 long j ;
02395 j=read_to_eoln( input[actual],oline ) ;
02396
02397 if ( j==None )
02398 {
02399 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02400 read_error=1 ;
02401 }
02402 }
02403
02404 void cmlfile::get_line_with_key ( long olabel , const char *okey , char *oline )
02405 {
02406 if ( !compiled )
02407 {
02408 compile() ;
02409 }
02410 if ( !stop[olabel].n )
02411 {
02412 oline[0]=0 ;
02413 return ;
02414 }
02415 if ( normal_read_disable )
02416 {
02417 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02418 oline[0]=0 ;
02419 read_error=1 ;
02420 return ;
02421 }
02422 long i=0,pos ;
02423 do
02424 {
02425 actual=stop[olabel].file[i] ;
02426 pos=stop[olabel].position[i] ;
02427 fseek( input[actual],pos,SEEK_SET ) ;
02428 fscanf( input[actual],"%s",buffer ) ;
02429 if ( !str_equal( okey,buffer ))
02430 {
02431 i++ ;
02432 }
02433 }
02434 while (( !str_equal( okey,buffer )) && ( i<stop[olabel].n )) ;
02435 if ( i==stop[olabel].n )
02436 {
02437 printf( "Key value %s does not occur in data for label %s.\n",okey,stop[olabel].word ) ;
02438 oline[0]=0 ;
02439 return ;
02440 }
02441 long j ;
02442 j=read_to_eoln( input[actual],oline ) ;
02443
02444 if ( j==None )
02445 {
02446 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02447 read_error=1 ;
02448 }
02449 }
02450
02451 void cmlfile::get_line_with_index ( long olabel , long oindex , char *oline )
02452 {
02453 if ( !compiled )
02454 {
02455 compile() ;
02456 }
02457 if ( !stop[olabel].n )
02458 {
02459 oline[0]=0 ;
02460 return ;
02461 }
02462 if ( normal_read_disable )
02463 {
02464 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02465 oline[0]=0 ;
02466 read_error=1 ;
02467 return ;
02468 }
02469 if ( oindex>=stop[olabel].n )
02470 {
02471 printf( "Index over possible value.\n" ) ;
02472 oline[0]=0 ;
02473 read_error=1 ;
02474 return ;
02475 }
02476
02477 actual=stop[olabel].file[oindex] ;
02478 fseek( input[actual],stop[olabel].position[oindex],SEEK_SET ) ;
02479
02480 long j ;
02481 j=read_to_eoln( input[actual],oline ) ;
02482
02483 if ( j==None )
02484 {
02485 printf( "Seems that some error occured reading data for label %s.\n",stop[olabel].word ) ;
02486 read_error=1 ;
02487 }
02488 }
02489
02490 void cmlfile::find_section ( long olabel , long &osection_rows )
02491 {
02492 if ( !compiled )
02493 {
02494 compile() ;
02495 }
02496 if ( block[olabel].files==0 )
02497 {
02498 osection_rows=0 ;
02499 return ;
02500 }
02501 if ( normal_read_disable )
02502 {
02503 printf( "Cannot read line input now because now reading SECTION data.\n" ) ;
02504 read_error=1 ;
02505 }
02506 block[olabel].actual=0 ;
02507 block[olabel].i=0 ;
02508 actual=block[olabel].file[0] ;
02509 osection_rows=block[olabel].rows_all ;
02510 fseek( input[actual],block[olabel].pos[0],SEEK_SET ) ;
02511 read_to_eoln( input[actual],buffer ) ;
02512 normal_read_disable=1 ;
02513 }
02514
02515 void cmlfile::get_section_line ( long olabel , char *oline )
02516 {
02517 if ( !compiled )
02518 {
02519 compile() ;
02520 }
02521 long i=block[olabel].actual ;
02522 if ( block[olabel].i>=block[olabel].rows[i] )
02523 {
02524 i++ ;
02525 if ( i>=files )
02526 {
02527 normal_read_disable=0 ;
02528 return ;
02529 }
02530 block[olabel].actual=i ;
02531 block[olabel].i=0 ;
02532 actual=block[olabel].file[i] ;
02533 fseek( input[actual],block[olabel].pos[i],SEEK_SET ) ;
02534 read_to_eoln( input[actual],buffer ) ;
02535 }
02536 long j ;
02537 j=read_to_eoln( input[actual],oline ) ;
02538 block[olabel].i++ ;
02539
02540 if ( j==None )
02541 {
02542 printf( "Seems that some error occured reading data for label %s.\n",block[olabel].word ) ;
02543 read_error=1 ;
02544 }
02545 }
02546
02547 void cmlfile::end_reading_section ( void )
02548 {
02549 normal_read_disable=0 ;
02550 }
02551
02552 void cmlfile::out ( long olabel , long ovalue )
02553 {
02554 if ( !output )
02555 {
02556 printf( "Cannot write to output file.\n" ) ;
02557 write_error=1 ;
02558 }
02559 fprintf( output,"%s %ld\n",stop[olabel].word,ovalue ) ;
02560 }
02561
02562 void cmlfile::out ( long olabel , double ovalue )
02563 {
02564 if ( !output )
02565 {
02566 printf( "Cannot write to output file.\n" ) ;
02567 write_error=1 ;
02568 }
02569 fprintf( output,"%s ",stop[olabel].word ) ;
02570 fprintf( output,double_format,ovalue ) ;
02571 fprintf( output,"\n" ) ;
02572 }
02573
02574
02575 void cmlfile::out ( long olabel , const char *ovalue )
02576 {
02577 if ( !output )
02578 {
02579 printf( "Cannot write to output file.\n" ) ;
02580 write_error=1 ;
02581 }
02582 fprintf( output,"%s ",stop[olabel].word ) ;
02583 long i=0,k=0 ;
02584 while ( ovalue[i] )
02585 {
02586 if ( ovalue[i]==' ' )
02587 {
02588 k=1 ;
02589 break ;
02590 }
02591 i++ ;
02592 }
02593 if ( k )
02594 {
02595 fputc( 34,output ) ;
02596 }
02597 fprintf( output,"%s",ovalue ) ;
02598 if ( k )
02599 {
02600 fputc( 34,output ) ;
02601 }
02602 fprintf( output,"%c",' ' ) ;
02603 fprintf( output,"\n" ) ;
02604 }
02605
02606 void cmlfile::out_label ( long olabel )
02607 {
02608 if ( !output )
02609 {
02610 printf( "Cannot write to output file.\n" ) ;
02611 write_error=1 ;
02612 }
02613 fprintf( output,"%s ",stop[olabel].word ) ;
02614 }
02615
02616 void cmlfile::out_long ( long ovalue )
02617 {
02618 if ( !output )
02619 {
02620 printf( "Cannot write to output file.\n" ) ;
02621 write_error=1 ;
02622 }
02623 fprintf( output,"%ld ",ovalue ) ;
02624 }
02625
02626 void cmlfile::out_double ( double ovalue )
02627 {
02628 if ( !output )
02629 {
02630 printf( "Cannot write to output file.\n" ) ;
02631 write_error=1 ;
02632 }
02633 fprintf( output,double_format,ovalue ) ;
02634 fprintf( output," " ) ;
02635 }
02636
02637 void cmlfile::out_string ( const char *ovalue )
02638 {
02639 if ( !output )
02640 {
02641 printf( "Cannot write to output file.\n" ) ;
02642 write_error=1 ;
02643 }
02644 long i=0,k=0 ;
02645 while ( ovalue[i] )
02646 {
02647 if ( ovalue[i]==' ' )
02648 {
02649 k=1 ;
02650 break ;
02651 }
02652 i++ ;
02653 }
02654 if ( k )
02655 {
02656 fputc( 34,output ) ;
02657 }
02658 fprintf( output,"%s",ovalue ) ;
02659 if ( k )
02660 {
02661 fputc( 34,output ) ;
02662 }
02663 fprintf( output,"%c",' ' ) ;
02664 }
02665
02666 void cmlfile::out_free_string ( const char *ovalue )
02667 {
02668 if ( !output )
02669 {
02670 printf( "Cannot write to output file.\n" ) ;
02671 write_error=1 ;
02672 }
02673 fprintf( output,"%s",ovalue ) ;
02674 }
02675
02676 void cmlfile::out_eoln ( void )
02677 {
02678 if ( !output )
02679 {
02680 printf( "Cannot write to output file.\n" ) ;
02681 write_error=1 ;
02682 }
02683 fprintf( output,"\n" ) ;
02684 }
02685
02686 void cmlfile::out_section ( long olabel )
02687 {
02688 if ( !output )
02689 {
02690 printf( "Cannot write to output file.\n" ) ;
02691 write_error=1 ;
02692 }
02693 fprintf( output,"%s %s\n",KeywordSection,block[olabel].word ) ;
02694 }
02695
02696 void cmlfile::out_data ( const char *oline )
02697 {
02698 if ( !output )
02699 {
02700 printf( "Cannot write to output file.\n" ) ;
02701 write_error=1 ;
02702 }
02703 fprintf( output,"%s\n",oline ) ;
02704 }
02705
02706 void cmlfile::out_section_end ( void )
02707 {
02708 if ( !output )
02709 {
02710 printf( "Cannot write to output file.\n" ) ;
02711 write_error=1 ;
02712 }
02713 fprintf( output,"%s\n",KeywordEndSection ) ;
02714 }
02715
02716 void cmlfile::clear_errors ( void )
02717 {
02718 open_error=0 ;
02719 read_error=0 ;
02720 write_error=0 ;
02721 }
02722
02723 long cmlfile::error_opening_file ( void )
02724 {
02725 return open_error ;
02726 }
02727
02728 long cmlfile::error_reading_file ( void )
02729 {
02730 return read_error ;
02731 }
02732
02733 long cmlfile::error_writing_file ( void )
02734 {
02735 return write_error ;
02736 }
02737
02738 long cmlfile::error_in_requirements ( void )
02739 {
02740 return requirement_insufficient ;
02741 }
02742
02743 long cmlfile::any_error ( void )
02744 {
02745 if ( open_error | read_error | write_error | requirement_insufficient )
02746 {
02747 return 1 ;
02748 }
02749 return 0 ;
02750 }
02751
02752 void cmlfile::open_next_input ( const char *ofname )
02753 {
02754 input[files]=fopen( ofname,"rt" ) ;
02755 if ( !input[files] )
02756 {
02757 printf( "Cannot open file %s.\n",ofname ) ;
02758 open_error=1 ;
02759 return ;
02760 }
02761 files++ ;
02762 }
02763
02764 void cmlfile::stat_section ( void )
02765 {
02766 fscanf( input[actual],"%s",buffer ) ;
02767 long i,j,b ;
02768 j=section_name( buffer ) ;
02769 if ( j==None )
02770 {
02771 printf( "Invalid section %s.\n",buffer ) ;
02772 return ;
02773 }
02774 i=block[j].files ;
02775 block[j].pos[i]=ftell( input[actual] ) ;
02776 block[j].end[i]=ftell( input[actual] ) ;
02777 block[j].file[i]=actual ;
02778 block[j].rows[i]=0 ;
02779
02780 b=read_to_eoln( input[actual],buffer ) ;
02781 b=read_to_eoln( input[actual],buffer ) ;
02782 if ( b==None )
02783 {
02784 printf( "Seems that some error occured reading data for section %s.\n",block[j].word ) ;
02785 read_error=1 ;
02786 return ;
02787 }
02788
02789 while ( !str_equal( KeywordEndSection,buffer ))
02790 {
02791 block[j].end[i]=ftell( input[actual] ) ;
02792 block[j].rows[i]++ ;
02793 read_to_eoln( input[actual],buffer ) ;
02794 if ( b==None )
02795 {
02796 printf( "Seems that some error occured reading data for section %s.\n",block[j].word ) ;
02797 read_error=1 ;
02798 return ;
02799 }
02800
02801 }
02802 block[j].rows_all+=block[j].rows[i] ;
02803 block[j].files++ ;
02804 }
02805
02806 void cmlfile::jump_over_section ( void )
02807 {
02808 fscanf( input[actual],"%s",buffer ) ;
02809 long j ;
02810 j=section_name( buffer ) ;
02811 if ( j==None )
02812 {
02813 printf( "Invalid section %s.\n",buffer ) ;
02814 return ;
02815 }
02816 long i=0 ;
02817 while ( block[j].file[i]!=actual )
02818 {
02819 i++ ;
02820 }
02821 fseek( input[actual],block[j].end[i],SEEK_SET ) ;
02822 }
02823
02824 long cmlfile::label ( const char *obuffer )
02825 {
02826 if ( obuffer[0]=='#' )
02827 {
02828 return Comment ;
02829 }
02830 if ( str_equal( KeywordSection,obuffer ))
02831 {
02832 return Section ;
02833 }
02834 if ( str_equal( KeywordEndSection,obuffer ))
02835 {
02836 return EndSection ;
02837 }
02838 if ( str_equal( KeywordFile,obuffer ))
02839 {
02840 return File ;
02841 }
02842 long i ;
02843 for ( i=0 ; i<labels ; i++ )
02844 {
02845 if ( str_equal( obuffer,stop[i].word ))
02846 {
02847 return i ;
02848 }
02849 }
02850 return None ;
02851 }
02852
02853 long cmlfile::section_name ( const char *obuffer )
02854 {
02855 long i ;
02856 for ( i=0 ; i<sections ; i++ )
02857 {
02858 if ( str_equal( block[i].word,obuffer ))
02859 {
02860 return i ;
02861 }
02862 }
02863 return None ;
02864 }