Reimplemented from confStruct. Definition at line 7 of file clientConf.cpp. 00007 { 00008 int errorVar = 0; 00009 regex_t regEx; 00010 regEx.re_nsub = subExpCount; 00011 regmatch_t* regMatch = (regmatch_t *) malloc(sizeof(regmatch_t) * regEx.re_nsub ); 00012 char filebuff[1024]; 00013 FILE* datei; 00014 int counter = 0; 00015 int counter2 = 0; 00016 int deziCount = 1; 00017 int found = 0; 00018 int tempValue = 0; 00019 char* filebuff2 = NULL; 00020 counter = 0; 00021 filebuff[0] = '\0'; 00022 errorVar = regcomp(®Ex, regExp, REG_EXTENDED); 00023 if( errorVar != 0 ){ 00024 return 1; 00025 } 00026 datei = fopen(filename,"r"); 00027 if(datei == NULL){ 00028 return 1; 00029 } 00030 fseek(datei,0 , SEEK_SET); 00031 while( !feof(datei) ){ 00032 fgets(filebuff, 80, datei); 00033 if(filebuff[0] == '#' || filebuff[0] == 10){ 00034 } 00035 else{ 00036 errorVar = regexec(®Ex, filebuff, regEx.re_nsub + 1, regMatch, 0); 00037 if( errorVar == REG_ESPACE ){ 00038 return 1; 00039 } 00040 else if( errorVar == REG_NOMATCH ){ 00041 return 3; 00042 } 00043 else{ 00044 counter = 0; 00045 found = 0; 00046 while(counter < this->validValuesCount && found == 0){ 00047 if( strncmp( this->validValues[counter], &filebuff[regMatch[1].rm_so], strlen(this->validValues[counter])) == 0 && regMatch[1].rm_eo == strlen(validValues[counter]) + regMatch[1].rm_so){ 00048 if(this->isInt[counter] == 1){ 00049 counter2 = regMatch[2].rm_eo - 1; 00050 tempValue = 0; 00051 deziCount = 1; 00052 while( counter2 >= regMatch[2].rm_so ){ 00053 tempValue = tempValue + (filebuff[counter2] - '0') * deziCount; 00054 counter2 = counter2 - 1; 00055 deziCount = deziCount *10; 00056 } 00057 this->intArray[counter] = tempValue; 00058 } 00059 else{ 00060 filebuff2 = new char[(regMatch[2].rm_eo - regMatch[2].rm_so) + 2]; 00061 if(filebuff2 == NULL){ 00062 printf("kann speicher nicht anlegen\n"); 00063 return 1; 00064 } 00065 filebuff2[0] = '\0'; 00066 strncat(filebuff2, &filebuff[regMatch[2].rm_so], regMatch[2].rm_eo - regMatch[2].rm_so); 00067 charArray[counter] = filebuff2; 00068 } 00069 this->confFound[counter] = 1; 00070 found = 1; 00071 } 00072 counter = counter + 1; 00073 } 00074 if( found == 0 ){ 00075 } 00076 } 00077 } 00078 filebuff[0] = '\0'; 00079 } 00080 counter = 0; 00081 return 0; 00082 }
|
1.5.1