int serverConf::readConfFromFile ( const char *  fileName  )  [private]

Reimplemented from confStruct.

Definition at line 8 of file serverConf.cpp.

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


Generated on Wed Jun 25 14:47:12 2008 for keyvil by  doxygen 1.5.1