Changeset 5018 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Aug 14, 2005, 11:05:01 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/util/ini_parser.cc
r5017 r5018 40 40 this->sections = NULL; 41 41 if (fileName != NULL) 42 this-> openFile(fileName);42 this->readFile(fileName); 43 43 } 44 44 … … 91 91 * @return true on success false otherwise; 92 92 */ 93 bool IniParser:: openFile(const char* fileName)93 bool IniParser::readFile(const char* fileName) 94 94 { 95 95 FILE* stream; //!< The stream we use to read the file. 96 97 98 96 if (sections != NULL) 99 97 deleteSections(); … … 101 99 return false; 102 100 101 printf("1\n"); 103 102 if( (stream = fopen (fileName, "r")) == NULL) 104 103 { … … 108 107 else 109 108 { 109 printf("2\n"); 110 110 this->currentEntry = NULL; 111 111 this->currentSection = NULL; … … 119 119 char* ptr; 120 120 121 rewind (stream);122 121 while( !feof( stream)) 123 122 { 124 123 // get next line 125 124 fgets (lineBuffer, PARSELINELENGHT, stream); 125 printf("%s", lineBuffer); 126 126 // remove newline char, and \0-terminate 127 127 if( (ptr = strchr( lineBuffer, '\n')) != NULL) 128 128 *ptr = 0; 129 129 // check for section identifyer 130 if( sscanf (lineBuffer, "[%s", buffer) == 1) 130 if (strlen(lineBuffer) <= 1) 131 printf("empty Line\n"); 132 else if( sscanf (lineBuffer, "[%s", buffer) == 1) 131 133 { 132 134 if( (ptr = strchr( buffer, ']')) != NULL) … … 137 139 strcpy(newSection->name, buffer); 138 140 newSection->entries = new tList<IniEntry>; 141 this->currentSection = newSection; 139 142 this->sections->add(newSection); 140 this->currentSection = newSection;141 143 } 142 144 } 145 // check for Entry identifier (Entry = Value) 143 146 else if( (ptr = strchr( lineBuffer, '=')) != NULL) 144 147 { … … 150 153 if( ptr == lineBuffer) 151 154 continue; 152 IniEntry* newEntry = new IniEntry;153 154 155 char* valueBegin = ptr+1; 155 156 while ((*valueBegin == ' ' || *valueBegin == '\t') && valueBegin <= lineBuffer + strlen(lineBuffer)) 156 157 ++valueBegin; 157 newEntry->value = new char[strlen(valueBegin)+1]; 158 strcpy(newEntry->value, valueBegin); 159 char* nameEnd = ptr-1, *nameBegin = lineBuffer; 158 char* nameBegin = lineBuffer; 160 159 while ((*nameBegin == ' ' || *nameBegin == '\t') && nameBegin < ptr) 161 160 ++nameBegin; 161 char* nameEnd = ptr-1; 162 162 while ((*nameEnd == ' ' || *nameEnd == '\t' ) && nameEnd >= nameBegin) 163 163 --nameEnd; 164 164 nameEnd[1] = '\0'; 165 newEntry->name = new char[strlen (nameBegin)]; 165 166 IniEntry* newEntry = new IniEntry; 167 newEntry->value = new char[strlen(valueBegin)+1]; 168 strcpy(newEntry->value, valueBegin); 169 newEntry->name = new char[strlen (nameBegin)+1]; 166 170 strcpy(newEntry->name, nameBegin); 167 171 -
orxonox/trunk/src/lib/util/ini_parser.h
r5017 r5018 42 42 ~IniParser (); 43 43 44 bool openFile(const char* name);44 bool readFile(const char* name); 45 45 46 46 bool getSection(const char* sectionName); -
orxonox/trunk/src/orxonox.cc
r5015 r5018 139 139 140 140 // initialize the Config-file 141 printf("wet\n"); 141 142 this->getConfigFile(); 142 143 143 144 144 // initialize everything … … 375 375 } 376 376 377 printf("finished inizialisation\n"); 377 378 orx->start(); 378 379 -
orxonox/trunk/src/orxonox.h
r4866 r5018 1 1 /*! 2 \file orxonox.h3 *Orxonox core functions2 * @file orxonox.h 3 * Orxonox core functions 4 4 */ 5 5
Note: See TracChangeset
for help on using the changeset viewer.