test_config *init_fill_test_config(char *configFile) { #define newStruct(type) (type *)MALLOC(sizeof(type)) char params[25]; // Create structure strcpy(params, ""); test_config *cfg = newStruct(test_config); cfg->general = newStruct(t_general); // Initialize structure strcpy(cfg->comment, "asf_test configuration file"); cfg->general->suite = (char *) MALLOC(sizeof(char)*100); strcpy(cfg->general->suite, ""); cfg->general->type = (char *) MALLOC(sizeof(char)*25); strcpy(cfg->general->type, ""); cfg->general->test_count = 0; cfg->general->status = (char *) MALLOC(sizeof(char)*25); strcpy(cfg->general->status, ""); return cfg; }
static vector<UniformData> FindUniformStructs(const string& shaderText) { static const string STRUCT_KEY = "struct"; vector<UniformData> result; size_t structLocation = shaderText.find(STRUCT_KEY); while (structLocation != string::npos) { structLocation += STRUCT_KEY.length() + 1; //Ignore the struct keyword and space size_t braceOpening = shaderText.find("{", structLocation); size_t braceClosing = shaderText.find("}", braceOpening); UniformData newStruct( FindUniformStructName(shaderText.substr(structLocation, braceOpening - structLocation)), FindUniformStructComponents(shaderText.substr(braceOpening, braceClosing - braceOpening))); result.push_back(newStruct); structLocation = shaderText.find(STRUCT_KEY, structLocation); } return result; }
int initialize() { debug("ok: initialize().start."); newStruct(); pSession->cClientOrServer = 's'; pSession->sCurrentPath = sDefaultCurrentPath; pSession->sCurrentPathForClient = ""; pSession->readyForSubcommand = 0; pSession->requestQueueMax = 10; pSession->pLocalPort = (char*)"5570";//sftp 69 is not usable pSession->sLocalFileAddress = sDefaultLocalFileAddress; pAboutReadFile->pOpenReadType = aDefaultOpenReadType; pAboutWriteFile->pOpenWriteType = aDefaultOpenWriteType; debug("ok: initialize().end."); return 0; }
test_config *read_test_config(char *configFile) { FILE *fConfig; test_config *cfg = NULL; char line[255], params[50], lib[100]; char *test=NULL, *p; strcpy(params, ""); cfg = init_fill_test_config(configFile); if (cfg == NULL) check_return(1, "Creating configuration structure.\n"); fConfig = fopen(configFile, "r"); if (!fConfig) return NULL; // Determine how many tests we actually have while (fgets(line, 255, fConfig) != NULL) { if (strchr(line, '[') && strchr(line, ']') && line[0] != '#' && !strncmp(line, "[General]", 9) == 0) cfg->general->test_count++; } cfg->test = (t_test **) MALLOC(sizeof(t_test *)*cfg->general->test_count); int num = -1; FCLOSE(fConfig); // Read all test cases along with the general information fConfig = FOPEN(configFile, "r"); strcpy(lib, ""); while (fgets(line, 255, fConfig) != NULL) { if (strncmp(line, "[General]", 9) == 0) strcpy(params, "general"); if (strcmp(params, "general") == 0) { test = read_param(line); if (strncmp(test, "suite", 5) == 0) strcpy(cfg->general->suite, read_str(line, "suite")); if (strncmp(test, "type", 4) == 0) strcpy(cfg->general->type, read_str(line, "type")); if (strncmp(test, "short configuration file", 24) == 0) cfg->general->short_config = read_int(line, "short configuration file"); if (strncmp(test, "status", 6) == 0) strcpy(cfg->general->status, read_str(line, "status")); } if (strchr(line, '[') && strchr(line, ']') && line[0] != '#' && !strncmp(line, "[General]", 9) == 0) { strcpy(params, "testcase"); num++; cfg->test[num] = newStruct(t_test); cfg->test[num]->test = (char *) MALLOC(sizeof(char)*100); strcpy(cfg->test[num]->test, ""); cfg->test[num]->file = (char *) MALLOC(sizeof(char)*1024); strcpy(cfg->test[num]->file, ""); cfg->test[num]->specs = (char *) MALLOC(sizeof(char)*100); strcpy(cfg->test[num]->specs, ""); cfg->test[num]->status = (char *) MALLOC(sizeof(char)*25); strcpy(cfg->test[num]->status, ""); if (strncmp(cfg->general->type, "library", 7) == 0) { cfg->test[num]->lib = (t_library *) MALLOC(sizeof(t_library)); cfg->test[num]->lib->name = (char *) MALLOC(sizeof(char)*255); } p = strchr(line, ']'); *p = '\0'; strcpy(cfg->test[num]->test, line+1); } if (strcmp(params, "testcase") == 0) { test = read_param(line); if (strncmp(test, "file", 4) == 0) strcpy(cfg->test[num]->file, read_str(line, "file")); if (strncmp(test, "specs", 5) == 0) strcpy(cfg->test[num]->specs, read_str(line, "specs")); if (strncmp(test, "status", 6) == 0) strcpy(cfg->test[num]->status, read_str(line, "status")); if (strncmp(test, "library function", 16) == 0) { strcpy(cfg->test[num]->lib->name, read_str(line, "library function")); if (strncmp(cfg->test[num]->lib->name, "get_cal_dn", 10) == 0) { init_library_function(cfg->test[num]->lib, "get_cal_dn"); strcpy(lib, "get_cal_dn"); } } if (strlen(lib) > 0 && strcmp_case(lib, "get_cal_dn") == 0) { if (strncmp_case(test, "meta file", 9) == 0) strcpy(cfg->test[num]->lib->get_cal_dn->meta_file, read_str(line, "meta file")); if (strncmp_case(test, "incidence angle", 15) == 0) cfg->test[num]->lib->get_cal_dn->incid = read_int(line, "incidence angle"); if (strncmp_case(test, "sample", 6) == 0) cfg->test[num]->lib->get_cal_dn->sample = read_int(line, "sample"); if (strncmp_case(test, "inDn", 4) == 0) cfg->test[num]->lib->get_cal_dn->inDn = read_float(line, "inDn"); if (strncmp_case(test, "bandExt", 7) == 0) strcpy(cfg->test[num]->lib->get_cal_dn->bandExt, read_str(line, "bandExt")); if (strncmp_case(test, "dbFlag", 6) == 0) cfg->test[num]->lib->get_cal_dn->dbFlag = read_int(line, "dbFlag"); if (strncmp(test, "expected value", 14) == 0) cfg->test[num]->lib->get_cal_dn->value = read_double(line, "expected value"); } } } if (test) FREE(test); else asfPrintError("Could not find manual tests in configuration file (%s).\n" "Does the configuration contains unit tests?\n", configFile); FCLOSE(fConfig); return cfg; }