コード例 #1
0
int main() {
    int fd0, fd1, fd2;
    pid_t pid = fork();
    if (pid < 0) {
        exit(1);
    } else if (pid != 0) {
        exit(0);
    }
    setsid();
    if (chdir("/") < 0) {
        exit(1);
    }
    fd0 = open("/dev/null", O_RDWR);
    fd1 = dup(0);
    fd2 = dup(0);
    FILE * g_pFile;
    g_pFile = fopen("/home/lvhongliang/autoAnswer/AutoAnswer/log.txt", "a+");
    const char* configLoc = "/home/lvhongliang/autoAnswer/AutoAnswer/configLoc.txt";
    ConfigFile config; 
    config.load(configLoc);
    QuestionVectorFactory qvFactory(&config);
    DBBase db;
    int conRet = db.openConnection(config.Value("database", "server").c_str(),
            config.Value("database", "dbname").c_str(),
            config.Value("database", "user").c_str(),
            config.Value("database", "password").c_str());
    if (200 != conRet) {
        cout << dberror(conRet);
        exit(1);
    }

    //fprintf(g_pFile, "%s\n", "all data is loaded successfully! start the web server...");
    RelatedQuestions ser(g_pFile, &qvFactory, &db);
    ser.serv(9999, 10);
    return 0;
}
コード例 #2
0
ファイル: defs.cpp プロジェクト: cryptobiu/MultiPartyPSI
std::string getValFromConfig(ConfigFile &config, const char* section, const char* valueName) {
    std::string value = config.Value(section,valueName);
    size_t first = value.find_first_not_of(' ');
    return value.substr(first, value.length()-first);
}