int MSG_db1_data::get_INFO_image_pixels( ) { if (! is_data_ok( )) return 0; return iniparser_getint(INFO, "Image:Pixels", chfstat.st_size/sizeof(short)); }
int MSG_db1_data::get_INFO_image_lines( ) { if (! is_data_ok( )) return 0; return iniparser_getint(INFO, "Image:Lines", 1); }
long MSG_db1_data::get_AoI_loff( ) { if (! is_data_ok( )) return 0; return (long) iniparser_getint(AoI, ":LOFF", 0); }
int MSG_db1_data::get_INFO_satellite_orbit( ) { if (! is_data_ok( )) return 0; return iniparser_getint(INFO, "Satellite:Orbit", 0); }
/** * \brief Load configuration from file to the Verse server context. * * \param vs_ctx The Verse server context. * \param file The pointer at FILE structure; */ void vs_read_config_file(struct VS_CTX *vs_ctx, const char *ini_file_name) { dictionary *ini_dict; ini_dict = iniparser_load((char*) ini_file_name); if(ini_dict != NULL) { char *user_auth_method; char *certificate_file_name; char *ca_certificate_file_name; char *private_key; char *fc_type; int fc_win_scale; int in_queue_max_size; int out_queue_max_size; int tcp_port_number; int ws_port_number; int udp_low_port_number; int udp_high_port_number; int max_session_count; #ifdef WITH_KERBEROS char *use_kerberos; #endif #ifdef WITH_OPENSSL /* Try to get TLS port number */ tcp_port_number = iniparser_getint(ini_dict, "Global:TLS_port", -1); if(tcp_port_number != -1) { if(tcp_port_number >= 1024 && tcp_port_number <= 65535) { vs_ctx->tcp_port = tcp_port_number; } else { v_print_log(VRS_PRINT_WARNING, "TLS port: %d out of range: 1024-65535\n", tcp_port_number); } } #else /* Try to get TCP port number */ tcp_port_number = iniparser_getint(ini_dict, "Global:TCP_port", -1); if(tcp_port_number != -1) { if(tcp_port_number >= 1024 && tcp_port_number <= 65535) { vs_ctx->tcp_port = tcp_port_number; } else { v_print_log(VRS_PRINT_WARNING, "TCP port: %d out of range: 1024-65535\n", tcp_port_number); } } #endif /* Try to get WebSocket port number */ ws_port_number = iniparser_getint(ini_dict, "Global:WS_port", -1); if(ws_port_number != -1) { if(ws_port_number >= 1024 && ws_port_number <= 65535) { vs_ctx->ws_port = ws_port_number; } else { v_print_log(VRS_PRINT_WARNING, "WebSocket port: %d out of range: 1024-65535\n", ws_port_number); } } /* Try to get lowest UDP port */ udp_low_port_number = iniparser_getint(ini_dict, "Global:UDP_port_low", -1); if(udp_low_port_number != -1) { if(udp_low_port_number >= 49152 && udp_low_port_number <= 65535) { vs_ctx->port_low = udp_low_port_number; } else { v_print_log(VRS_PRINT_WARNING, "UDP port: %d out of range: 49152-65535\n", udp_low_port_number); } } udp_high_port_number = iniparser_getint(ini_dict, "Global:UDP_port_high", -1); if(udp_high_port_number != -1) { if(udp_high_port_number >= 49152 && udp_high_port_number <= 65535) { vs_ctx->port_high = udp_high_port_number; } else { v_print_log(VRS_PRINT_WARNING, "UDP port: %d out of range: 49152-65535\n", udp_high_port_number); } } max_session_count = iniparser_getint(ini_dict, "Global:MaxSessionCount", -1); if(max_session_count != -1) { vs_ctx->max_sessions = max_session_count; } /* Try to load section [Users] */ user_auth_method = iniparser_getstring(ini_dict, "Users:Method", NULL); if(user_auth_method != NULL && strcmp(user_auth_method, "file") == 0) { char *file_type; v_print_log(VRS_PRINT_DEBUG_MSG, "user_auth_method: %s\n", user_auth_method); file_type = iniparser_getstring(ini_dict, "Users:FileType", NULL); if(file_type != NULL && strcmp(file_type, "csv") == 0) { char *csv_file_name; v_print_log(VRS_PRINT_DEBUG_MSG, "file_type: %s\n", file_type); csv_file_name = iniparser_getstring(ini_dict, "Users:File", NULL); if(csv_file_name !=NULL) { vs_ctx->auth_type = AUTH_METHOD_CSV_FILE; vs_ctx->csv_user_file = strdup(csv_file_name); printf("csv_file_name: %s\n", csv_file_name); } } } /* Try to load section [Users] for LDAP */ #ifdef WITH_LDAP if (user_auth_method != NULL && strcmp(user_auth_method, "ldap") == 0) { int ldap_version = 0; v_print_log(VRS_PRINT_DEBUG_MSG, "user_auth_method: %s\n", user_auth_method); ldap_version = iniparser_getint(ini_dict, "Users:Version", 0 ); if (ldap_version > 0 && ldap_version <= 3) { char *ldap_hostname, *ldap_DN, *ldap_pass, *ldap_base, *ldap_LOS; v_print_log(VRS_PRINT_DEBUG_MSG, "LDAP version %d\n", ldap_version); vs_ctx->ldap_version = ldap_version; ldap_hostname = iniparser_getstring(ini_dict, "Users:Hostname", NULL ); ldap_DN = iniparser_getstring(ini_dict, "Users:UserDN", NULL ); ldap_pass = iniparser_getstring(ini_dict, "Users:Pass", NULL ); ldap_base = iniparser_getstring(ini_dict, "Users:Base", NULL ); ldap_LOS = iniparser_getstring(ini_dict, "Users:LoadOnStart", NULL ); if (ldap_hostname != NULL && ldap_DN != NULL && ldap_pass != NULL && ldap_base != NULL ) { if (strcmp(ldap_LOS, "yes") == 0) { vs_ctx->auth_type = AUTH_METHOD_LDAP; v_print_log(VRS_PRINT_DEBUG_MSG, "Users will be loaded on startup.\n"); } else { char *cache_file; cache_file = iniparser_getstring(ini_dict, "Users:File", NULL ); vs_ctx->auth_type = AUTH_METHOD_LDAP_LOAD_AT_LOGIN; vs_ctx->created_user_file = strdup(cache_file); v_print_log(VRS_PRINT_DEBUG_MSG, "Users will be loaded at login.\n"); v_print_log(VRS_PRINT_DEBUG_MSG, "File for saving user accounts: %s\n", cache_file); } vs_ctx->ldap_hostname = strdup(ldap_hostname); vs_ctx->ldap_user = strdup(ldap_DN); vs_ctx->ldap_passwd = strdup(ldap_pass); vs_ctx->ldap_search_base = strdup(ldap_base); v_print_log(VRS_PRINT_DEBUG_MSG, "LDAP server hostname: %s\n", ldap_hostname); v_print_log(VRS_PRINT_DEBUG_MSG, "LDAP user DN: %s\n", ldap_DN); v_print_log(VRS_PRINT_DEBUG_MSG, "LDAP search base: %s\n", ldap_base); } } } #endif /* Try to load section [Security] */ #ifdef WITH_KERBEROS use_kerberos = iniparser_getstring(ini_dict, "Security:UseKerberos", NULL); if(use_kerberos != NULL && strcmp(use_kerberos, "yes") == 0) { char *service_name, *domain_name; service_name = iniparser_getstring(ini_dict, "Security:Service", NULL); domain_name = iniparser_getstring(ini_dict, "Security:Domain", NULL); vs_ctx->use_krb5 = USE_KERBEROS; if(domain_name != NULL) vs_ctx->domain_name = strdup(domain_name); if(service_name != NULL) vs_ctx->service_name = strdup(service_name); v_print_log(VRS_PRINT_DEBUG_MSG, "Kerberos will be used\n"); } #endif certificate_file_name = iniparser_getstring(ini_dict, "Security:Certificate", NULL); if(certificate_file_name != NULL) { v_print_log(VRS_PRINT_DEBUG_MSG, "certificate_file_name: %s\n", certificate_file_name); vs_ctx->public_cert_file = strdup(certificate_file_name); } /* Certificate of certificate authority */ ca_certificate_file_name = iniparser_getstring(ini_dict, "Security:CACertificate", NULL); if(ca_certificate_file_name != NULL) { v_print_log(VRS_PRINT_DEBUG_MSG, "ca_certificate_file_name: %s\n", ca_certificate_file_name); vs_ctx->ca_cert_file = strdup(ca_certificate_file_name); } /* Server private key */ private_key = iniparser_getstring(ini_dict, "Security:PrivateKey", NULL); if(private_key != NULL) { v_print_log(VRS_PRINT_DEBUG_MSG, "private_key: %s\n", private_key); vs_ctx->private_cert_file = strdup(private_key); } /* Type of Flow Control */ fc_type = iniparser_getstring(ini_dict, "FlowControl:Type", NULL); if(fc_type != NULL) { if(strcmp(fc_type, "tcp_like")==0) { v_print_log(VRS_PRINT_DEBUG_MSG, "flow_control: %s\n", fc_type); vs_ctx->fc_meth = FC_TCP_LIKE; } else if(strcmp(fc_type, "none")==0) { v_print_log(VRS_PRINT_DEBUG_MSG, "flow_control type: %s\n", fc_type); vs_ctx->fc_meth = FC_NONE; } } /* Scale of Flow Control window */ fc_win_scale = iniparser_getint(ini_dict, "FlowControl:WinScale", -1); if(fc_win_scale != -1) { if(fc_win_scale >= 0 && fc_win_scale <= 255) { v_print_log(VRS_PRINT_DEBUG_MSG, "flow_control scale: %d\n", fc_win_scale); vs_ctx->rwin_scale = fc_win_scale; } } /* Maximal size of incoming queue */ in_queue_max_size = iniparser_getint(ini_dict, "InQueue:MaxSize", -1); if(in_queue_max_size != -1) { if(in_queue_max_size > 0 && in_queue_max_size <= INT_MAX) { v_print_log(VRS_PRINT_DEBUG_MSG, "in_queue max size: %d\n", in_queue_max_size); vs_ctx->in_queue_max_size = in_queue_max_size; } } /* Maximal size of outgoing queue */ out_queue_max_size = iniparser_getint(ini_dict, "OutQueue:MaxSize", -1); if(out_queue_max_size != -1) { if(out_queue_max_size > 0 && out_queue_max_size <= INT_MAX) { v_print_log(VRS_PRINT_DEBUG_MSG, "in_queue max size: %d\n", out_queue_max_size); vs_ctx->in_queue_max_size = out_queue_max_size; } } iniparser_freedict(ini_dict); } }
long MSG_db1_data::get_AoI_cfac( ) { if (! is_data_ok( )) return 0; return (long) iniparser_getint(AoI, ":CFAC", 0); }
void Test_iniparser_getint(CuTest *tc) { unsigned i; char key_name[64]; dictionary *dic; const struct { int num; const char *value; } good_val[] = { { 0, "0" }, { 1, "1" }, { -1, "-1" }, { 1000, "1000" }, { 077, "077" }, { -01000, "-01000" }, { 0xFFFF, "0xFFFF" }, { -0xFFFF, "-0xFFFF" }, { 0x4242, "0x4242" }, { 0, NULL} /* must be last */ }; const char *bad_val[] = { "", "notanumber", "0x", "k2000", " ", "0xG1" }; /* NULL test */ CuAssertIntEquals(tc, -42, iniparser_getint(NULL, NULL, -42)); CuAssertIntEquals(tc, -42, iniparser_getint(NULL, "dummy", -42)); /* Check the def return element */ dic = dictionary_new(10); CuAssertIntEquals(tc, 42, iniparser_getint(dic, "dummy", 42)); CuAssertIntEquals(tc, 0xFFFF, iniparser_getint(dic, NULL, 0xFFFF)); CuAssertIntEquals(tc, -0xFFFF, iniparser_getint(dic, "dummy", -0xFFFF)); dictionary_del(dic); /* Generic dictionary */ dic = dictionary_new(10); for (i = 0; good_val[i].value != NULL; ++i) { sprintf(key_name, "int:value%d", i); dictionary_set(dic, key_name, good_val[i].value); } for (i = 0; good_val[i].value != NULL; ++i) { sprintf(key_name, "int:value%d", i); CuAssertIntEquals(tc, good_val[i].num, iniparser_getint(dic, key_name, 0)); } dictionary_del(dic); /* Test bad names */ dic = dictionary_new(10); for (i = 0; i < sizeof (bad_val) / sizeof (char *); ++i) { sprintf(key_name, "int:bad%d", i); dictionary_set(dic, key_name, bad_val[i]); } for (i = 0; i < sizeof (bad_val) / sizeof (char *); ++i) { sprintf(key_name, "int:bad%d", i); CuAssertIntEquals(tc, 0, iniparser_getint(dic, key_name, 0)); } dictionary_del(dic); }
int MSG_db1_data::get_INFO_image_nproducts( ) { if (! is_data_ok( )) return 0; return iniparser_getint(INFO, "Image:nProducts", 10); }
//-------------------------------------------------- // read the conf file //-------------------------------------------------- int configfile_Read(char * ini_name, ALARMCENTER* ptAlarmCenter) { dictionary * ini ; ini = iniparser_load(ini_name); if (ini==NULL) { fprintf(stderr, "cannot parse file: %s\n", ini_name); return -1 ; } ptAlarmCenter->iOnOff = iniparser_getint(ini, "main:onoff", 0); ptAlarmCenter->iAlarmMode = iniparser_getint(ini, "main:alarmmode", 1); ptAlarmCenter->iAlarmTime = iniparser_getint(ini, "main:alarmtime", 10); ptAlarmCenter->iWarningMode = iniparser_getint(ini, "main:warningmode", 1); ptAlarmCenter->iWarningTime = iniparser_getint(ini, "main:warningtime", 5); ptAlarmCenter->iAlarmSchwelle1 = iniparser_getint(ini, "main:alarmschwelle1", 1); ptAlarmCenter->iAlarmSchwelle2 = iniparser_getint(ini, "main:alarmschwelle2", 50); ptAlarmCenter->iOnDelay = iniparser_getint(ini, "main:ondelay", 50); ptAlarmCenter->iAlarmDelay = iniparser_getint(ini, "main:alarmdelay", 50); ptAlarmCenter->iWarningDelay = iniparser_getint(ini, "main:warningdelay", 50); ptAlarmCenter->iStartHour = iniparser_getint(ini, "main:starthour", 2); ptAlarmCenter->iStopHour = iniparser_getint(ini, "main:stophour", 23); ptAlarmCenter->iTcpPort = iniparser_getint(ini, "tcp:port", 1234); iniparser_freedict(ini); return 0 ; }
/** * \brief Load configuration from file to the Verse server context. * * \param vs_ctx The Verse server context. * \param file The pointer at FILE structure; */ void vs_read_config_file(struct VS_CTX *vs_ctx, const char *ini_file_name) { dictionary *ini_dict; ini_dict = iniparser_load((char*) ini_file_name); if(ini_dict != NULL) { char *user_auth_method; char *certificate_file_name; char *ca_certificate_file_name; char *private_key; char *fc_type; #ifdef WITH_MONGODB char *mongodb_server_hostname; int mongodb_server_port; char *mongodb_server_db_name; char *mongodb_user; char *mongodb_pass; #endif int fc_win_scale; int in_queue_max_size; int out_queue_max_size; int tcp_port_number; int ws_port_number; int udp_low_port_number; int udp_high_port_number; int max_session_count; v_print_log(VRS_PRINT_DEBUG_MSG, "Reading config file: %s\n", ini_file_name); #ifdef WITH_OPENSSL /* Try to get TLS port number */ tcp_port_number = iniparser_getint(ini_dict, "Global:TLS_port", -1); if(tcp_port_number != -1) { if(tcp_port_number >= 1024 && tcp_port_number <= 65535) { vs_ctx->tcp_port = tcp_port_number; } else { v_print_log(VRS_PRINT_WARNING, "TLS port: %d out of range: 1024-65535\n", tcp_port_number); } } #else /* Try to get TCP port number */ tcp_port_number = iniparser_getint(ini_dict, "Global:TCP_port", -1); if(tcp_port_number != -1) { if(tcp_port_number >= 1024 && tcp_port_number <= 65535) { vs_ctx->tcp_port = tcp_port_number; } else { v_print_log(VRS_PRINT_WARNING, "TCP port: %d out of range: 1024-65535\n", tcp_port_number); } } #endif /* Try to get WebSocket port number */ ws_port_number = iniparser_getint(ini_dict, "Global:WS_port", -1); if(ws_port_number != -1) { if(ws_port_number >= 1024 && ws_port_number <= 65535) { vs_ctx->ws_port = ws_port_number; } else { v_print_log(VRS_PRINT_WARNING, "WebSocket port: %d out of range: 1024-65535\n", ws_port_number); } } /* Try to get lowest UDP port */ udp_low_port_number = iniparser_getint(ini_dict, "Global:UDP_port_low", -1); if(udp_low_port_number != -1) { if(udp_low_port_number >= 49152 && udp_low_port_number <= 65535) { vs_ctx->port_low = udp_low_port_number; } else { v_print_log(VRS_PRINT_WARNING, "UDP port: %d out of range: 49152-65535\n", udp_low_port_number); } } udp_high_port_number = iniparser_getint(ini_dict, "Global:UDP_port_high", -1); if(udp_high_port_number != -1) { if(udp_high_port_number >= 49152 && udp_high_port_number <= 65535) { vs_ctx->port_high = udp_high_port_number; } else { v_print_log(VRS_PRINT_WARNING, "UDP port: %d out of range: 49152-65535\n", udp_high_port_number); } } max_session_count = iniparser_getint(ini_dict, "Global:MaxSessionCount", -1); if(max_session_count != -1) { vs_ctx->max_sessions = max_session_count; } /* Try to load section [Users] */ user_auth_method = iniparser_getstring(ini_dict, "Users:Method", NULL); if(user_auth_method != NULL && strcmp(user_auth_method, "file") == 0) { char *file_type; v_print_log(VRS_PRINT_DEBUG_MSG, "user_auth_method: %s\n", user_auth_method); file_type = iniparser_getstring(ini_dict, "Users:FileType", NULL); if(file_type != NULL && strcmp(file_type, "csv") == 0) { char *csv_file_name; v_print_log(VRS_PRINT_DEBUG_MSG, "file_type: %s\n", file_type); csv_file_name = iniparser_getstring(ini_dict, "Users:File", NULL); if(csv_file_name !=NULL) { vs_ctx->auth_type = AUTH_METHOD_CSV_FILE; if(vs_ctx->csv_user_file != NULL) { free(vs_ctx->csv_user_file); } vs_ctx->csv_user_file = strdup(csv_file_name); v_print_log(VRS_PRINT_DEBUG_MSG, "csv_file_name: %s\n", csv_file_name); } } } /* Try to load section [Security] */ certificate_file_name = iniparser_getstring(ini_dict, "Security:Certificate", NULL); if(certificate_file_name != NULL) { v_print_log(VRS_PRINT_DEBUG_MSG, "certificate_file_name: %s\n", certificate_file_name); if(vs_ctx->public_cert_file != NULL) { free(vs_ctx->public_cert_file); } vs_ctx->public_cert_file = strdup(certificate_file_name); } /* Certificate of certificate authority */ ca_certificate_file_name = iniparser_getstring(ini_dict, "Security:CACertificate", NULL); if(ca_certificate_file_name != NULL) { v_print_log(VRS_PRINT_DEBUG_MSG, "ca_certificate_file_name: %s\n", ca_certificate_file_name); vs_ctx->ca_cert_file = strdup(ca_certificate_file_name); } /* Server private key */ private_key = iniparser_getstring(ini_dict, "Security:PrivateKey", NULL); if(private_key != NULL) { v_print_log(VRS_PRINT_DEBUG_MSG, "private_key: %s\n", private_key); if(vs_ctx->private_cert_file != NULL) { free(vs_ctx->private_cert_file); } vs_ctx->private_cert_file = strdup(private_key); } /* Type of Flow Control */ fc_type = iniparser_getstring(ini_dict, "FlowControl:Type", NULL); if(fc_type != NULL) { if(strcmp(fc_type, "tcp_like")==0) { v_print_log(VRS_PRINT_DEBUG_MSG, "flow_control: %s\n", fc_type); vs_ctx->fc_meth = FC_TCP_LIKE; } else if(strcmp(fc_type, "none")==0) { v_print_log(VRS_PRINT_DEBUG_MSG, "flow_control type: %s\n", fc_type); vs_ctx->fc_meth = FC_NONE; } } /* Scale of Flow Control window */ fc_win_scale = iniparser_getint(ini_dict, "FlowControl:WinScale", -1); if(fc_win_scale != -1) { if(fc_win_scale >= 0 && fc_win_scale <= 255) { v_print_log(VRS_PRINT_DEBUG_MSG, "flow_control scale: %d\n", fc_win_scale); vs_ctx->rwin_scale = fc_win_scale; } } /* Maximal size of incoming queue */ in_queue_max_size = iniparser_getint(ini_dict, "InQueue:MaxSize", -1); if(in_queue_max_size != -1) { if(in_queue_max_size > 0) { v_print_log(VRS_PRINT_DEBUG_MSG, "in_queue max size: %d\n", in_queue_max_size); vs_ctx->in_queue_max_size = in_queue_max_size; } } /* Maximal size of outgoing queue */ out_queue_max_size = iniparser_getint(ini_dict, "OutQueue:MaxSize", -1); if(out_queue_max_size != -1) { if(out_queue_max_size > 0) { v_print_log(VRS_PRINT_DEBUG_MSG, "in_queue max size: %d\n", out_queue_max_size); vs_ctx->in_queue_max_size = out_queue_max_size; } } #ifdef WITH_MONGODB /* Hostname of MongoDB server */ mongodb_server_hostname = iniparser_getstring(ini_dict, "MongoDB:ServerHostname", NULL); if(mongodb_server_hostname != NULL) { v_print_log(VRS_PRINT_DEBUG_MSG, "mongodb server hostname: %s\n", mongodb_server_hostname); vs_ctx->mongodb_server = strdup(mongodb_server_hostname); } /* Port of MongoDB server */ mongodb_server_port = iniparser_getint(ini_dict, "MongoDB:ServerPort", -1); if(mongodb_server_port != -1) { v_print_log(VRS_PRINT_DEBUG_MSG, "mongodb server port: %d\n", mongodb_server_port); vs_ctx->mongodb_port = mongodb_server_port; } /* MongoDB database name used by Verse server */ mongodb_server_db_name = iniparser_getstring(ini_dict, "MongoDB:DatabaseName", NULL); if(mongodb_server_db_name != NULL) { v_print_log(VRS_PRINT_DEBUG_MSG, "mongodb server database name: %s\n", mongodb_server_db_name); vs_ctx->mongodb_db_name = strdup(mongodb_server_db_name); } /* Username used for authentication at MongoDB */ mongodb_user = iniparser_getstring(ini_dict, "MongoDB:Username", NULL); if(mongodb_user != NULL) { v_print_log(VRS_PRINT_DEBUG_MSG, "mongodb server username: %s\n", mongodb_user); vs_ctx->mongodb_user = strdup(mongodb_user); } /* Password used for authentication at MongoDB */ mongodb_pass = iniparser_getstring(ini_dict, "MongoDB:Password", NULL); if(mongodb_user != NULL) { int i; v_print_log(VRS_PRINT_DEBUG_MSG, "mongodb server password: "******"*"); } v_print_log_simple(VRS_PRINT_DEBUG_MSG, "\n"); vs_ctx->mongodb_pass = strdup(mongodb_pass); } #endif iniparser_freedict(ini_dict); } else { v_print_log(VRS_PRINT_WARNING, "Unable to load config file: %s\n", ini_file_name); } }
int Config::rint(const string &key) { return iniparser_getint(ini, (char *)key.c_str(), -1); }
int main ( int argc, char *argv[]){ int i; int state; int sizeOfDimension; int success = 1; int FTI_APP_RANK; herr_t status; threeD ***ptr = allocateLinearMemory(XSIZE, YSIZE, ZSIZE ); threeD *devPtr; int result; MPI_Init(&argc, &argv); result = FTI_Init(argv[1], MPI_COMM_WORLD); if (result == FTI_NREC) { exit(RECOVERY_FAILED); } int crash = atoi(argv[2]); int level = atoi(argv[3]); memset(&ptr[0][0][0],0, sizeof(threeD) * (XSIZE * YSIZE * ZSIZE)); int numGpus = getProperties(); MPI_Comm_rank(FTI_COMM_WORLD,&FTI_APP_RANK); setDevice(FTI_APP_RANK%numGpus); dictionary *ini = iniparser_load( argv[1] ); int grank; MPI_Comm_rank(MPI_COMM_WORLD,&grank); int nbHeads = (int)iniparser_getint(ini, "Basic:head", -1); int finalTag = (int)iniparser_getint(ini, "Advanced:final_tag", 3107); int nodeSize = (int)iniparser_getint(ini, "Basic:node_size", -1); int headRank = grank - grank%nodeSize; FTIT_complexType coordinateDef; FTIT_type threeDType; FTI_AddSimpleField( &coordinateDef, &FTI_INTG, offsetof( threeD, x),0, "X"); FTI_AddSimpleField( &coordinateDef, &FTI_INTG, offsetof( threeD, y),1, "y"); FTI_AddSimpleField( &coordinateDef, &FTI_INTG, offsetof( threeD, z),2, "z"); FTI_AddSimpleField( &coordinateDef, &FTI_INTG, offsetof( threeD, id),3, "id"); FTI_InitComplexType(&threeDType, &coordinateDef, 4 , sizeof(threeD), "ThreeD", NULL); if ( (nbHeads<0) || (nodeSize<0) ) { printf("wrong configuration (for head or node-size settings)! %d %d\n",nbHeads, nodeSize); MPI_Abort(MPI_COMM_WORLD, -1); } allocateMemory((void **) &devPtr, (XSIZE * YSIZE * ZSIZE*sizeof(threeD))); FTI_Protect(0, devPtr, (XSIZE * YSIZE * ZSIZE),threeDType); int dimLength[3] = {ZSIZE,YSIZE,XSIZE}; if (grank == 0) for ( i =0 ; i < 3; i++){ printf("Dimension is %d size is %d\n", dimLength[i], XSIZE*YSIZE*ZSIZE*sizeof(threeDType) / (1024*1024)); } FTI_DefineDataset(0, 3, dimLength , "GPU TOPOLOGY" , NULL); state = FTI_Status(); if ( state == INIT ){ executeKernel(devPtr); FTI_Checkpoint(1,level); if ( crash ) { if( nbHeads > 0 ) { int value = FTI_ENDW; MPI_Send(&value, 1, MPI_INT, headRank, finalTag, MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); } MPI_Finalize(); exit(0); } }else{ result = FTI_Recover(); if (result != FTI_SCES) { exit(RECOVERY_FAILED); } hostCopy(devPtr, &ptr[0][0][0],(XSIZE * YSIZE * ZSIZE*sizeof(threeD))); } threeD ***validationMemory= allocateLinearMemory(XSIZE, YSIZE, ZSIZE ); initData(&validationMemory[0][0][0]); if (state == RESTART || state == KEEP) { int tmp; result = memcmp(&validationMemory[0][0][0], &ptr[0][0][0],(XSIZE * YSIZE * ZSIZE*sizeof(threeD))); MPI_Allreduce(&result, &tmp, 1, MPI_INT, MPI_SUM, FTI_COMM_WORLD); result = tmp; } deallocateLinearMemory(ZSIZE , ptr); deallocateLinearMemory(ZSIZE , validationMemory); freeCuda(devPtr); if (FTI_APP_RANK == 0 && (state == RESTART || state == KEEP)) { if (result == 0) { printf("[SUCCESSFUL]\n"); } else { printf("[NOT SUCCESSFUL]\n"); success=0; } } MPI_Barrier(FTI_COMM_WORLD); FTI_Finalize(); MPI_Finalize(); if (success == 1) return 0; else exit(DATA_CORRUPT); }
// loading from gamefolder/gameinfo.txt or gamefolder/liblist.gam // (currently loading from liblist is unsupported by this method - using the handler method to convert) bool CGameInfo::LoadFromFile(const tString &asPath) { DevMsg(eMsgType_Info, "Trying to load game info from %s...", asPath.c_str()); dictionary *pGameInfoDict = iniparser_load(asPath.c_str()); if(!pGameInfoDict) { DevMsg(eMsgMsg_Error, "Can't find game info file \"%s\"!", asPath.c_str()); return false; }; // setup default values /* GameInfo->gamefolder = gamedir; VectorSet(GameInfo->client_mins[0], 0, 0, 0 ); VectorSet(GameInfo->client_mins[1], -16, -16, -36); VectorSet(GameInfo->client_mins[2], -32, -32, -32); VectorSet(GameInfo->client_mins[3], -16, -16, -18); VectorSet(GameInfo->client_maxs[0], 0, 0, 0 ); VectorSet(GameInfo->client_maxs[1], 16, 16, 36); VectorSet(GameInfo->client_maxs[2], 32, 32, 32); VectorSet(GameInfo->client_maxs[3], 16, 16, 18); */ msBaseDir = iniparser_getstring(pGameInfoDict, "basedir", ""); msFallDir = iniparser_getstring(pGameInfoDict, "fallback_dir", ""); // GameInfo->falldir[0] = '\0'; msGameDir = iniparser_getstring(pGameInfoDict, "gamedir", ""); msTitle = iniparser_getstring(pGameInfoDict, "title", "New Game"); msSPEntName = iniparser_getstring(pGameInfoDict, "sp_entity", "info_player_start"); msMPEntName = iniparser_getstring(pGameInfoDict, "mp_entity", "info_player_deathmatch"); msGameLib = iniparser_getstring(pGameInfoDict, "gamedll", "dlls/hl.dll"); msGameLibPath = iniparser_getstring(pGameInfoDict, "dllpath", "cl_dlls"); msStartMap = iniparser_getstring(pGameInfoDict, "startmap", ""); /*else if(token == "startmap") { pfile = COM_ParseFile(pfile, GameInfo->startmap); mpFileSystem->StripExtension(GameInfo->startmap); // HQ2: Amen has extension .bsp }*/ msTrainMap = iniparser_getstring(pGameInfoDict, "trainmap", ""); /*else if(token == "trainmap") { pfile = COM_ParseFile(pfile, GameInfo->trainmap); mpFileSystem->StripExtension(GameInfo->trainmap); // HQ2: Amen has extension .bsp }*/ msIconPath = iniparser_getstring(pGameInfoDict, "icon", "game.ico"); /*else if(token == "icon") { pfile = COM_ParseFile(pfile, GameInfo->iconpath); mpFileSystem->DefaultExtension(GameInfo->iconpath, ".ico"); }*/ msGameURL = iniparser_getstring(pGameInfoDict, "url_info", ""); msUpdateURL = iniparser_getstring(pGameInfoDict, "url_update", ""); msType = iniparser_getstring(pGameInfoDict, "type", ""); msDate = iniparser_getstring(pGameInfoDict, "date", ""); mfVersion = iniparser_getdouble(pGameInfoDict, "version", 1.0f); mnSize = iniparser_getint(pGameInfoDict, "size", 0); mnMaxEdicts = clamp(600, iniparser_getint(pGameInfoDict, "max_edicts", 900), 4096); mnMaxTempEnts = clamp(300, iniparser_getint(pGameInfoDict, "max_tempents", 500), 2048); mnMaxBeams = clamp(64, iniparser_getint(pGameInfoDict, "max_beams", 128), 512); mnMaxParticles = clamp(1024, iniparser_getint(pGameInfoDict, "max_particles", 4096), 131072); // Todo: finalize it tString sGameMode = iniparser_getstring(pGameInfoDict, "gamemode", ""); if(sGameMode == "singleplayer_only") mnGameMode = 1; else if(sGameMode == "multiplayer_only") mnGameMode = 2; mbSecure = iniparser_getboolean(pGameInfoDict, "secure", 0) ? true : false; mbNoModels = iniparser_getboolean(pGameInfoDict, "nomodels", 0) ? true : false; mnSoundClipDist = iniparser_getint(pGameInfoDict, "soundclip_dist", 1536); // Todo: implement vector parsing else if(!strnicmp(token, "hull", 4))
int MSG_db1_data::get_INFO_image_bitsperpixel( ) { if (! is_data_ok( )) return 0; return iniparser_getint(INFO, "Image:BitsPerPixel", 10); }
int MSG_db1_data::get_AoI_npixels( ) { if (! is_data_ok( )) return -1; return iniparser_getint(AoI, ":nPixels", chfstat.st_size/sizeof(short)); }
int MSG_db1_data::get_INFO_image_nchannels( ) { if (! is_data_ok( )) return 0; return iniparser_getint(INFO, "Image:nChannels", 10); }
int MSG_db1_data::get_AoI_nlines( ) { if (! is_data_ok( )) return -1; return iniparser_getint(AoI, ":nLines", 1); }
int MSG_db1_data::get_channel_INFO_bitsperpixel( ) { if (! is_data_ok( )) return 0; snprintf(infochuse, INFOCHLEN, "Channel%d:BitsPerPixel", chnum); return iniparser_getint(INFO, infochuse, 10); }
int main(int argc, char **argv) { char challenge_old[CHALLENGELEN + 1], challenge_new[CHALLENGELEN + 1], repose_old[RESPONSELEN], repose_new[RESPONSELEN], passphrase_old[PASSPHRASELEN + 1], passphrase_new[PASSPHRASELEN + 1]; char challengefilename[sizeof(CHALLENGEDIR) + 11 /* "/challenge-" */ + 10 /* unsigned int in char */ + 1], challengefiletmpname[sizeof(CHALLENGEDIR) + 11 /* "/challenge-" */ + 10 /* unsigned int in char */ + 7 /* -XXXXXX */ + 1]; int challengefile = 0, challengefiletmp = 0; struct timeval tv; int i; int8_t rc = EXIT_FAILURE; /* cryptsetup */ char * device_name; int8_t luks_slot = -1; struct crypt_device *cd; crypt_status_info cs; crypt_keyslot_info ck; /* yubikey */ YK_KEY * yk; uint8_t yk_slot = SLOT_CHAL_HMAC2; unsigned int serial = 0; /* iniparser */ dictionary * ini; char section_ykslot[10 /* unsigned int in char */ + 1 + sizeof(CONFYKSLOT) + 1]; char section_luksslot[10 /* unsigned int in char */ + 1 + sizeof(CONFLUKSSLOT) + 1]; /* initialize random seed */ gettimeofday(&tv, NULL); srand(tv.tv_usec * tv.tv_sec); memset(challenge_old, 0, CHALLENGELEN + 1); memset(challenge_new, 0, CHALLENGELEN + 1); memset(repose_old, 0, RESPONSELEN); memset(repose_new, 0, RESPONSELEN); memset(passphrase_old, 0, PASSPHRASELEN + 1); memset(passphrase_new, 0, PASSPHRASELEN + 1); if ((ini = iniparser_load(CONFIGFILE)) == NULL) { rc = EXIT_FAILURE; fprintf(stderr, "Could not parse configuration file.\n"); goto out10; } if ((device_name = iniparser_getstring(ini, "general:" CONFDEVNAME, NULL)) == NULL) { rc = EXIT_FAILURE; /* read from crypttab? */ /* get device from currently open devices? */ fprintf(stderr, "Could not read LUKS device from configuration file.\n"); goto out20; } /* init and open first Yubikey */ if ((rc = yk_init()) < 0) { perror("yk_init() failed"); goto out20; } if ((yk = yk_open_first_key()) == NULL) { rc = EXIT_FAILURE; perror("yk_open_first_key() failed"); goto out30; } /* read the serial number from key */ if ((rc = yk_get_serial(yk, 0, 0, &serial)) < 0) { perror("yk_get_serial() failed"); goto out40; } /* get the yk slot */ sprintf(section_ykslot, "%d:" CONFYKSLOT, serial); yk_slot = iniparser_getint(ini, "general:" CONFYKSLOT, yk_slot); yk_slot = iniparser_getint(ini, section_ykslot, yk_slot); switch (yk_slot) { case 1: case SLOT_CHAL_HMAC1: yk_slot = SLOT_CHAL_HMAC1; break; case 2: case SLOT_CHAL_HMAC2: default: yk_slot = SLOT_CHAL_HMAC2; break; } /* get the luks slot */ sprintf(section_luksslot, "%d:" CONFLUKSSLOT, serial); luks_slot = iniparser_getint(ini, section_luksslot, luks_slot); if (luks_slot < 0) { rc = EXIT_FAILURE; fprintf(stderr, "Please set LUKS key slot for Yubikey with serial %d!\n", serial); printf("Add something like this to " CONFIGFILE ":\n\n[%d]\nluks slot = 1\n", serial); goto out40; } /* get random number and limit to printable ASCII character (32 to 126) */ for(i = 0; i < CHALLENGELEN; i++) challenge_new[i] = (rand() % (126 - 32)) + 32; /* do challenge/response and encode to hex */ if ((rc = yk_challenge_response(yk, yk_slot, true, CHALLENGELEN, (unsigned char *)challenge_new, RESPONSELEN, (unsigned char *)repose_new)) < 0) { perror("yk_challenge_response() failed"); goto out40; } yubikey_hex_encode((char *)passphrase_new, (char *)repose_new, 20); /* initialize crypt device */ if ((rc = crypt_init_by_name(&cd, device_name)) < 0) { fprintf(stderr, "Device %s failed to initialize.\n", device_name); goto out40; } /* these are the filenames for challenge * we need this for reading and writing */ sprintf(challengefilename, CHALLENGEDIR "/challenge-%d", serial); sprintf(challengefiletmpname, CHALLENGEDIR "/challenge-%d-XXXXXX", serial); /* write new challenge to file */ if ((rc = challengefiletmp = mkstemp(challengefiletmpname)) < 0) { fprintf(stderr, "Could not open file %s for writing.\n", challengefiletmpname); goto out50; } if ((rc = write(challengefiletmp, challenge_new, CHALLENGELEN)) < 0) { fprintf(stderr, "Failed to write challenge to file.\n"); goto out60; } challengefiletmp = close(challengefiletmp); /* get status of crypt device * We expect this to be active (or busy). It is the actual root device, no? */ cs = crypt_status(cd, device_name); if (cs != CRYPT_ACTIVE && cs != CRYPT_BUSY) { rc = EXIT_FAILURE; fprintf(stderr, "Device %s is invalid or inactive.\n", device_name); goto out60; } ck = crypt_keyslot_status(cd, luks_slot); if (ck == CRYPT_SLOT_INVALID) { rc = EXIT_FAILURE; fprintf(stderr, "Key slot %d is invalid.\n", luks_slot); goto out60; } else if (ck == CRYPT_SLOT_ACTIVE || ck == CRYPT_SLOT_ACTIVE_LAST) { /* read challenge from file */ if ((rc = challengefile = open(challengefilename, O_RDONLY)) < 0) { perror("Failed opening challenge file for reading"); goto out60; } if ((rc = read(challengefile, challenge_old, CHALLENGELEN)) < 0) { perror("Failed reading challenge from file"); goto out60; } challengefile = close(challengefile); /* finished reading challenge */ /* do challenge/response and encode to hex */ if ((rc = yk_challenge_response(yk, yk_slot, true, CHALLENGELEN, (unsigned char *)challenge_old, RESPONSELEN, (unsigned char *)repose_old)) < 0) { perror("yk_challenge_response() failed"); goto out60; } yubikey_hex_encode((char *)passphrase_old, (char *)repose_old, 20); if ((rc = crypt_keyslot_change_by_passphrase(cd, luks_slot, luks_slot, passphrase_old, PASSPHRASELEN, passphrase_new, PASSPHRASELEN)) < 0) { fprintf(stderr, "Could not update passphrase for key slot %d.\n", luks_slot); goto out60; } if ((rc = unlink(challengefilename)) < 0) { fprintf(stderr, "Failed to delete old challenge file.\n"); goto out60; } } else { /* ck == CRYPT_SLOT_INACTIVE */ if ((rc = crypt_keyslot_add_by_passphrase(cd, luks_slot, NULL, 0, passphrase_new, PASSPHRASELEN)) < 0) { fprintf(stderr, "Could add passphrase for key slot %d.\n", luks_slot); goto out60; } } if ((rc = rename(challengefiletmpname, challengefilename)) < 0) { fprintf(stderr, "Failed to rename new challenge file.\n"); goto out60; } rc = EXIT_SUCCESS; out60: /* close the challenge file */ if (challengefile) close(challengefile); if (challengefiletmp) close(challengefiletmp); if (access(challengefiletmpname, F_OK) == 0 ) unlink(challengefiletmpname); out50: /* free crypt context */ crypt_free(cd); out40: /* close Yubikey */ if (!yk_close_key(yk)) perror("yk_close_key() failed"); out30: /* release Yubikey */ if (!yk_release()) perror("yk_release() failed"); out20: /* free iniparser dictionary */ iniparser_freedict(ini); out10: /* wipe response (cleartext password!) from memory */ /* This is statically allocated and always save to wipe! */ memset(challenge_old, 0, CHALLENGELEN + 1); memset(challenge_new, 0, CHALLENGELEN + 1); memset(repose_old, 0, RESPONSELEN); memset(repose_new, 0, RESPONSELEN); memset(passphrase_old, 0, PASSPHRASELEN + 1); memset(passphrase_new, 0, PASSPHRASELEN + 1); return rc; }