/***************************************************************************************************************************** open Prepares the database for use. An existing database is opened or otherwise an empty database is created. If the database is openend a table _META with meta info is loaded into a dictionary _META. The dictionary key is the code of the data element. A data element is either a tabel (dimension/event) or a field (characteristic/property). The value of the dictionary is the MET_INFO structure. This structure contains meta data about the data element. If the database is created an empty table _META is created. The function calls virtual functions, db_, which must be overriden by a derived class for a specific database implementation. ******************************************************************************************************************************/ void ARAS::open(DBInfo dbInfo) { if (isopen) return; // store db information this->dbInfo = dbInfo; // open or create database // performs the database specific initialization code, the specific information to be used is stored in the struct DBInfo. db_init_database(); // performs the database specific code to check whether a database alreay exists and open it. if (db_open_database()) { // read _META table from database into dictionary _META TABLE values; db_select_table("_META", {"CODE","INFO"}, values); for (auto i : values) _META.insert(std::pair<std::string, META_INFO>(i[0], META_INFO(i[1]))); } else { // performs the database specific code to create a new database based on DBInfo. db_create_database(); // create table _META: define the columns META_INFO imeta(data_type::DIM, 0, "_META", "", "", "_META", "CODE", 0, 0, 0, 0); META_INFO icode(data_type::STR, SIZE_META_CODE_MAX, "_META", "", "","_META", "", 0, 0, 1, 0); META_INFO idescs(data_type::STR, SIZE_DESCS_MAX, "_META", "", "", "_META", "", 0, 0, 0, 0); META_INFO idescl(data_type::STR, SIZE_DESCL_MAX, "_META", "", "", "_META", "", 0, 0, 0, 0); META_INFO iinfo(data_type::STR, 0, "_META", "", "", "_META", "",0, 0, 0, 0); // define the table META_TABLE meta = { { "_META", "Meta data", "Meta data", imeta }, { "CODE", "CODE", "CODE", icode }, { "DESCS", "Short Description", "Short Description", idescs }, { "DESCL", "Long Description", "Long Description", idescl }, { "INFO", "INFO", "INFO", iinfo } }; // performs the database specific code to create a new table db_create_table(meta); // load the meta data into the dictionary and the database table _META for (auto i : meta) insert_meta(i); } }
mBOOL MPluginList::ini_startup() { FILE *fp; char line[MAX_STRBUF_LEN]; int n, ln; MPlugin *pmatch; if(!valid_gamedir_file(inifile)) { META_ERROR("ini: Metamod plugins file empty or missing: %s", inifile); RETURN_ERRNO(mFALSE, ME_NOFILE); } full_gamedir_path(inifile, inifile); fp=fopen(inifile, "r"); if(!fp) { META_ERROR("ini: Unable to open plugins file '%s': %s", inifile, strerror(errno)); RETURN_ERRNO(mFALSE, ME_NOFILE); } META_LOG("ini: Begin reading plugins list: %s", inifile); for(n=0, ln=1; !feof(fp) && fgets(line, sizeof(line), fp) && n < size; ln++) { // Remove line terminations. char *cp; if((cp=strrchr(line, '\r'))) *cp='\0'; if((cp=strrchr(line, '\n'))) *cp='\0'; // Parse directly into next entry in array if(!plist[n].ini_parseline(line)) { if(meta_errno==ME_FORMAT) META_ERROR("ini: Skipping malformed line %d of %s", ln, inifile); continue; } // Check for a duplicate - an existing entry with this pathname. if(find(plist[n].pathname)) { // Should we check platform specific level here? META_INFO("ini: Skipping duplicate plugin, line %d of %s: %s", ln, inifile, plist[n].pathname); continue; } // Check for a matching platform with different platform specifics // level. if(NULL != (pmatch=find_match(&plist[n]))) { if(pmatch->pfspecific >= plist[n].pfspecific) { META_DEBUG(1, ("ini: Skipping plugin, line %d of %s: plugin with higher platform specific level already exists. (%d >= %d)", ln, inifile, pmatch->pfspecific, plist[n].pfspecific)); continue; } META_DEBUG(1, ("ini: Plugin in line %d overrides existing plugin with lower platform specific level %d, ours %d", ln, pmatch->pfspecific, plist[n].pfspecific)); int _index = pmatch->index; memset(pmatch, 0, sizeof(MPlugin)); pmatch->index = _index; } plist[n].action=PA_LOAD; META_LOG("ini: Read plugin config for: %s", plist[n].desc); n++; endlist=n; // mark end of list } META_LOG("ini: Finished reading plugins list: %s; Found %d plugins to load", inifile, n); fclose(fp); if(!n) { META_ERROR("ini: Warning; no plugins found to load?"); } return(mTRUE); }