bool mimeInit(const char *pszFilepath) { if (m_mimelist != NULL) return false; m_mimelist = qconfig_parse_file(NULL, pszFilepath, '=', true); if (m_mimelist == NULL) return false; return true; }
int main(void) { #ifdef DISABLE_QCONFIG printf("qconfig extension is disabled at compile time.\n"); return 1; #else qlisttbl_t *tbl = qconfig_parse_file(NULL, CONF_PATH, '=', true); if (tbl == NULL) { printf("Failed to open '" CONF_PATH "'.\n"); return -1; } tbl->debug(tbl, stdout); return 0; #endif }
/** * configuration parser * * @param pConf ServerConfig structure * @param pszFilePath file path of egis.conf * @return true if successful otherwise returns false */ bool loadConfig(struct ServerConfig *pConf, char *pszFilePath) { if (pszFilePath == NULL || !strcmp(pszFilePath, "")) { return false; } // parse configuration file qlisttbl_t *conflist = qconfig_parse_file(NULL, pszFilePath, '=', true); if (conflist == NULL) { DEBUG("Can't open file %s", pszFilePath); return false; } // copy to structure qstrcpy(pConf->szConfigFile, sizeof(pConf->szConfigFile), pszFilePath); fetch2Str(conflist, pConf->szPidFile, "PidFile"); fetch2Str(conflist, pConf->szMimeFile, "MimeFile"); fetch2Int(conflist, pConf->nPort, "Port"); fetch2Int(conflist, pConf->nStartServers, "StartServers"); fetch2Int(conflist, pConf->nMinSpareServers, "MinSpareServers"); fetch2Int(conflist, pConf->nMaxSpareServers, "MaxSpareServers"); fetch2Int(conflist, pConf->nMaxIdleSeconds, "MaxIdleSeconds"); fetch2Int(conflist, pConf->nMaxClients, "MaxClients"); fetch2Int(conflist, pConf->nMaxRequestsPerChild, "MaxRequestsPerChild"); fetch2Bool(conflist, pConf->bEnableKeepAlive, "EnableKeepAlive"); fetch2Int(conflist, pConf->nMaxKeepAliveRequests, "MaxKeepAliveRequests"); fetch2Int(conflist, pConf->nConnectionTimeout, "ConnectionTimeout"); fetch2Bool(conflist, pConf->bIgnoreOverConnection, "IgnoreOverConnection"); fetch2Int(conflist, pConf->nResponseExpires, "ResponseExpires"); fetch2Str(conflist, pConf->szDocumentRoot, "DocumentRoot"); fetch2Str(conflist, pConf->szAllowedMethods, "AllowedMethods"); fetch2Str(conflist, pConf->szDirectoryIndex, "DirectoryIndex"); fetch2Bool(conflist, pConf->bEnableLua, "EnableLua"); fetch2Str(conflist, pConf->szLuaScript, "LuaScript"); fetch2Bool(conflist, pConf->bEnableStatus, "EnableStatus"); fetch2Str(conflist, pConf->szStatusUrl, "StatusUrl"); fetch2Str(conflist, pConf->szErrorLog, "ErrorLog"); fetch2Str(conflist, pConf->szAccessLog, "AccessLog"); fetch2Int(conflist, pConf->nLogRotate, "LogRotate"); fetch2Int(conflist, pConf->nLogLevel, "LogLevel"); // check config checkConfig(pConf); // // free resources // conflist->free(conflist); return true; }