CIniFile::~CIniFile() { FreeAllTheStuff(); #ifdef WITH_HASH free(m_Hash); #endif }
int CIniFile::Load(const char *filename) { // open the model file FILE *fp = fopen(filename, "rb"); //FILE *fp = fopen(filename, "r"); if (fp == NULL) { ScutLog("error cannot load ini file %s\n", filename); return 1; } // if we already have a file loaded, free it first if (Valid()) { FreeAllTheStuff(); } //------------------->lrb //char str[256], section[256]; char str[300], section[256]; //<-------------------lrb section[0] = '\0'; while (fgets(str, 300, fp)) {//while (fgets(str, 256, fp)) { trim(str); // trim all the blanks or linefeeds // skip all comment lines or empty lines if (!str[0] || str[0] == ';' || str[0] == '/' || str[0] == '#') continue; int length = strlen(str); char *p; //-------------->lrb //<--------------lrb // check if this is a session line (e.g., [SECTION]) if (str[0] == '[' && str[length - 1] == ']') { strcpy(section, &str[1]); section[length - 2] = 0; // remove the ] trim(section); // trim section name after removing [] } else if ((p = strchr(str, '=')) != NULL) { *(p++) = '\0'; trim(str); // /<--------------------lrb // while((rt = strchr(p,'\\')) != NULL ) // { // *rt='\n'; // } // -------------------->lrb trim(p); Set(section, str, p); } } fclose(fp); // load completed; close the file return 0; }
// initialize the navigation map. void CWorld::MapInit() { m_iLastCoverSearch = 0; FreeAllTheStuff(); }
CWorld::~CWorld() { FreeAllTheStuff(); }