int fake_main(int argc, char** argv) { struct FunProp* funProp = NULL; int result = readConfFile("conf/sample.conf", &funProp); struct FunProp* ptr = funProp; while(ptr != NULL) { printf("Key: %s, FunName: %s, LibPath: %s, FunEntry: %s.\n", ptr->key, ptr->funName, ptr->libPath, ptr->funEntry); ptr = ptr->next; } destroyFunProp(&funProp); printf("Read Code: %d.\n", result); //printf("Test strcmp: %d.\n", strcmp("aaav", "aaa")); return 0; }
int readLibAndShow() { printf("The config file path(Enter 's' to load ./conf/sample.conf):"); char filePath[256]; memset(filePath, 0, 256); scanf("%s", filePath); if(filePath[0] == 's') { strcpy(filePath, "./conf/sample.conf"); } struct FunProp* funProp = NULL; int result = readConfFile(filePath, &funProp); if(result < 0) { printf("Load config file error."); return -1; } selectAndExecuteTheFun(funProp); destroyFunProp(&funProp); return 0; }
void doProcessing (int sock) { int n; char buffer[256]; bzero(buffer, 256); n = read(sock, buffer, 255); if (n < 0) { perror("ERROR reading from socket"); exit(1); } printf("Here is the message: %s\n", buffer); readConfFile(); n = write(sock, "OK.", 18); if (n < 0) { perror("ERROR writing to socket"); exit(1); } }
int main() { try { clock_t tStart = clock(); readConfFile(); cout<<"Started the program\n"; //cout<<tabIndex; DBConnection *squidLog = new DBConnection(); squidLog->dbConnOpen("127.0.0.1","3306","root","simple","squid"); string logReadQuery = "select * from access_log_new where id > ?;"; PreparedStatement *pstm = squidLog->conn->prepareStatement(logReadQuery); pstm->setInt(1,tabIndex); squidLog->res = pstm->executeQuery(); /*DBConnection *squidLog = new DBConnection(); squidLog->dbConnOpen("127.0.0.1","3306","root","simple","squid"); squidLog->tableName = "access_log"; squidLog->setReadPstmt(1,squidLog->tableName,"",""); squidLog->readTable();*/ statLog = new DBConnection(); createStatistics(squidLog,statLog); /*grossStatisticsAcc(statLog->tableNameAcc); grossStatisticsDen(statLog->tableNameDen); createDomainStatisticsAcc(statLog->tableNameAcc); createUserStatisticsAcc(statLog->tableNameAcc); createDomainStatisticsDen(statLog->tableNameDen); createUserStatisticsDen(statLog->tableNameDen);*/ writeConfFile(); printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); cout<<"End Of program \n"; } catch (sql::SQLException &e) { cout << "# ERR: SQLException in " << __FILE__; cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl; cout << "# ERR: " << e.what(); cout << " (MySQL error code: " << e.getErrorCode(); cout << ", SQLState: " << e.getSQLState() << " )" << endl; } catch (exception& e) { cout << "# ERR File: " << __FILE__; cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl; cout << e.what() << '\n'; } return 0; }
//********************************************************** // Global Function Implement //********************************************************** BOOLEAN configure(void){ getfilePath(); if(!readConfFile() || !readMasterFile()){ return FALSE; }else{ return TRUE; } }
void build_effective_args(int argc, char *argv[], effective_args_t *effective_args) { int i; char *linebuffer = (char *) malloc(MAX_CMDLINE_BUFFER_LENGTH); if (!linebuffer) { traceError("Unable to allocate memory"); exit(1); } snprintf(linebuffer, MAX_CMDLINE_BUFFER_LENGTH, "%s", argv[0]); #ifdef WIN32 for (i = 0; i < (int) strlen(linebuffer); i++) if (linebuffer[i] == '\\') linebuffer[i] = '/'; #endif for (i = 1; i < argc; ++i) { if (argv[i][0] == '@') { if (readConfFile(&argv[i][1], linebuffer) < 0) exit(1); /* <<<<----- check */ } else if ((strlen(linebuffer) + strlen(argv[i]) + 2) < MAX_CMDLINE_BUFFER_LENGTH) { strncat(linebuffer, " ", 1); strncat(linebuffer, argv[i], strlen(argv[i])); } else { traceError("too many argument"); exit(1); } } /* strip trailing spaces */ while (strlen(linebuffer) && linebuffer[ strlen(linebuffer) - 1 ] == ' ') linebuffer[ strlen(linebuffer) - 1 ] = '\0'; /* build the new argv from the linebuffer */ buildargv(linebuffer, effective_args); if (linebuffer) { free(linebuffer); linebuffer = NULL; } /* {int k;for(k=0;k<effectiveargc;++k) printf("%s\n",effectiveargv[k]);} */ }
/** * Read a property file, filling in the requested key-values. Returns 0 * when reading the property file succeeded. */ inline int readProps(confkeyval *ckv, const char *path) { char file[1024]; FILE *cnf; snprintf(file, 1024, "%s/" MEROPROPFILE, path); if ((cnf = fopen(file, "r")) != NULL) { readConfFile(ckv, cnf); fclose(cnf); return(0); } return(1); }
DNSList::DNSList(QWidget *parent, EIPType type) : QDialog(parent), ui(new Ui::DNSList) { ui->setupUi(this); success = false; readConfFile(); //Set default values in no file or no entries in file if (!servers_v4.size()) { for (unsigned int i=0; i<default_servers_v4_size; i++) servers_v4.push_back(default_servers_v4[i]); } if (!servers_v6.size()) { for (unsigned int i=0; i<default_servers_v6_size; i++) servers_v6.push_back(default_servers_v6[i]); } if (eIPV4 == type) { for (int i=0; i<servers_v4.size(); i++) { QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText(0, servers_v4[i].mIP); item->setText(1, servers_v4[i].mProvider); item->setText(2, servers_v4[i].mLocation); ui->list->addTopLevelItem(item); } }else{ //ipv6 for (int i=0; i<servers_v6.size(); i++) { QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText(0, servers_v6[i].mIP); item->setText(1, servers_v6[i].mProvider); item->setText(2, servers_v6[i].mLocation); ui->list->addTopLevelItem(item); } } //ui->list->setRowCount(servers_size+1); ui->list->setColumnWidth(0, 200); }
bool Settings::readConfFile() { return readConfFile(store["config_file"]); }
//*************************************************** // Global function //*************************************************** void configure(){ getfilePath(); readConfFile(); readMasterFile(); logDecollator(); }
void FSM::VM<X>::init(const std::string &conf, const std::string &luaFile) { readConfFile(conf, luaFile); compileFile(luaFile); }