Changeset 2551 in orxonox.OLD for orxonox/trunk/src/ini_parser.cc
- Timestamp:
- Oct 11, 2004, 12:53:43 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/ini_parser.cc
r2190 r2551 63 63 int IniParser::get_section( char* section) 64 64 { 65 bInSection = false; 66 if( stream == NULL) return -1; 67 68 char linebuffer[PARSELINELENGHT]; 69 char secbuffer[PARSELINELENGHT]; 70 char* ptr; 71 72 rewind (stream); 73 while( !feof( stream)) 65 bInSection = false; 66 if( stream == NULL) return -1; 67 68 char linebuffer[PARSELINELENGHT]; 69 char secbuffer[PARSELINELENGHT]; 70 char* ptr; 71 72 rewind (stream); 73 while( !feof( stream)) 74 { 75 // get next line 76 fgets (linebuffer, PARSELINELENGHT, stream); 77 // remove newline char 78 if( (ptr = strchr( linebuffer, '\n')) != NULL) *ptr = 0; 79 // check for section identifyer 80 if( sscanf (linebuffer, "[%s", secbuffer) == 1) 74 81 { 75 // get next line 76 fgets (linebuffer, PARSELINELENGHT, stream); 77 // remove newline char 78 if( (ptr = strchr( linebuffer, '\n')) != NULL) *ptr = 0; 79 // check for section identifyer 80 if( sscanf (linebuffer, "[%s", secbuffer) == 1) 82 if( (ptr = strchr( secbuffer, ']')) != NULL) 83 { 84 *ptr = 0; 85 if( !strcmp( secbuffer, section)) 81 86 { 82 if( (ptr = strchr( secbuffer, ']')) != NULL) 83 { 84 *ptr = 0; 85 if( !strcmp( secbuffer, section)) 86 { 87 bInSection = true; 88 return 0; 89 } 90 } 87 bInSection = true; 88 return 0; 91 89 } 90 } 92 91 } 93 return -1; 92 } 93 return -1; 94 94 } 95 95
Note: See TracChangeset
for help on using the changeset viewer.