static int do_crypto_test(void *param) { int ret; if(param == NULL) { printf("please input param:\n"); printf(" test_accvisio -v verify passwd\n"); printf(" test_accvisio -w write passwd\n"); return 0; } if(strcmp((char *)param, "-v") == 0) { cryptoInit(); ret = crypetoVerify(buf_passwd); if(ret == 0) printf("password verify success...\n"); else printf("password wrong...\n"); cryptoDestroy(); } else if(strcmp((char *)param, "-w") == 0) { cryptoInit(); ret = cryptoWriteSeed(buf_passwd); if(ret == 0) printf("write passwd success...\n"); else printf("write password failed...\n"); cryptoDestroy(); } return 0; }
bool serverInit ( Server *self, ServerInfo *serverInfo ) { // Make a private copy if (!(serverInfoInit ( &self->info, serverInfo->serverType, &serverInfo->routerInfo, serverInfo->workersInfo, serverInfo->workersInfoCount, serverInfo->output))) { error("Cannot init the ServerInfo"); return false; } // Initialize crypto module for decrypting packet if (!(cryptoInit())) { error ("Cannot initialize crypto module."); return false; } // Initialize router if (!(self->router = routerNew (&serverInfo->routerInfo))) { error("Cannot allocate a new Router."); return false; } // Initialize workers - Start N worker threads. if (!(self->workers = malloc (sizeof(Worker *) * serverInfo->routerInfo.workersCount))) { error("Cannot allocate enough Workers."); return false; } for (uint16_t workerId = 0; workerId < serverInfo->routerInfo.workersCount; workerId++) { // Allocate a new worker if (!(self->workers[workerId] = workerNew (&serverInfo->workersInfo[workerId]))) { error("Cannot allocate a new worker"); return false; } } return true; }