| 5 | 
   | 
 #include <ctype.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 6 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 7 | 
   | 
 #include "inifile.h" | 
 
 
 
 
 
 
 
 
 
 
 
 | 8 | 
 < | 
 /* | 
 
 
 
 
 
 
 
 
 
 | 8 | 
 > | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 9 | 
   | 
 char* inifile_cleanstr(char* str) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 10 | 
   | 
 { | 
 
 
 
 
 
 
 
 
 | 11 | 
 + | 
         int i; | 
 
 
 
 
 
 
 
 
 | 12 | 
 + | 
         for (i = strlen(str) - 1; i >= 0; i --) | 
 
 
 
 
 
 
 
 
 | 13 | 
 + | 
                 if (!isspace(str[i])) | 
 
 
 
 
 
 
 
 
 | 14 | 
 + | 
                 { | 
 
 
 
 
 
 
 
 
 | 15 | 
 + | 
                         str[i + 1] = '\0'; | 
 
 
 
 
 
 
 
 
 | 16 | 
 + | 
                         break; | 
 
 
 
 
 
 
 
 
 | 17 | 
 + | 
                 } | 
 
 
 
 
 
 
 
 
 | 18 | 
 + | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 19 | 
   | 
         while (isspace(*str)) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 20 | 
   | 
                 str++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 21 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 | 22 | 
 < | 
         int i; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 23 | 
 < | 
         for (i = 0; str[i]; i ++) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 22 | 
 > | 
         return str; | 
 
 
 
 
 
 | 23 | 
 > | 
 } | 
 
 
 
 
 
 | 24 | 
 > | 
  | 
 
 
 
 
 
 | 25 | 
 > | 
 int64_t inifile_parseint(const char* str, bool issigned) | 
 
 
 
 
 
 | 26 | 
 > | 
 { | 
 
 
 
 
 
 | 27 | 
 > | 
         int64_t ret = 0; | 
 
 
 
 
 
 | 28 | 
 > | 
         bool neg = false; | 
 
 
 
 
 
 | 29 | 
 > | 
         if (str[0] == '0' && str[1] == 'x') | 
 
 
 
 
 
 
 
 
 
 
 
 | 30 | 
   | 
         { | 
 
 
 
 
 
 
 
 
 
 
 
 | 31 | 
 < | 
                 if  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 | 
 > | 
                 int i; | 
 
 
 
 
 
 | 32 | 
 > | 
                 if (str[2] == '\0') | 
 
 
 
 
 
 | 33 | 
 > | 
                         return 0x100000000LL; | 
 
 
 
 
 
 | 34 | 
 > | 
                  | 
 
 
 
 
 
 | 35 | 
 > | 
                 for (i = 0, str += 2; *str; i++, str++) | 
 
 
 
 
 
 | 36 | 
 > | 
                 { | 
 
 
 
 
 
 | 37 | 
 > | 
                         if (i == 8) | 
 
 
 
 
 
 | 38 | 
 > | 
                                 return 0x100000000LL; | 
 
 
 
 
 
 | 39 | 
 > | 
                          | 
 
 
 
 
 
 | 40 | 
 > | 
                         ret <<= 4; | 
 
 
 
 
 
 | 41 | 
 > | 
                         if (*str >= '0' && *str <= '9') | 
 
 
 
 
 
 | 42 | 
 > | 
                                 ret |= *str - '0'; | 
 
 
 
 
 
 | 43 | 
 > | 
                         else if (*str >= 'a' && *str <= 'f') | 
 
 
 
 
 
 | 44 | 
 > | 
                                 ret |= *str - 'a' + 10; | 
 
 
 
 
 
 | 45 | 
 > | 
                         else if (*str >= 'A' && *str <= 'F') | 
 
 
 
 
 
 | 46 | 
 > | 
                                 ret |= *str - 'A' + 10; | 
 
 
 
 
 
 | 47 | 
 > | 
                         else | 
 
 
 
 
 
 | 48 | 
 > | 
                                 return 0x100000000LL; | 
 
 
 
 
 
 | 49 | 
 > | 
                 } | 
 
 
 
 
 
 | 50 | 
 > | 
                 return ret; | 
 
 
 
 
 
 
 
 
 
 
 
 | 51 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 | 52 | 
 < | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 53 | 
 < | 
         return str; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 | 
 > | 
         else if ((*str >= '0' && *str <= '9') || (neg = (*str == '-'))) | 
 
 
 
 
 
 | 53 | 
 > | 
         { | 
 
 
 
 
 
 | 54 | 
 > | 
                 int i; | 
 
 
 
 
 
 | 55 | 
 > | 
                 if (neg) | 
 
 
 
 
 
 | 56 | 
 > | 
                         str++; | 
 
 
 
 
 
 | 57 | 
 > | 
                 for (i = 0; *str; i++, str++) | 
 
 
 
 
 
 | 58 | 
 > | 
                 { | 
 
 
 
 
 
 | 59 | 
 > | 
                         if (i == 10) | 
 
 
 
 
 
 | 60 | 
 > | 
                                 return 0x100000000LL; | 
 
 
 
 
 
 | 61 | 
 > | 
                         else if (i == 9 && !issigned && (ret > 429496729LL || (ret == 429496729LL && *str > '5'))) | 
 
 
 
 
 
 | 62 | 
 > | 
                                 return 0x100000000LL; | 
 
 
 
 
 
 | 63 | 
 > | 
                         else if (i == 9 && issigned && (ret > 214748364LL || (ret == 214748364LL && *str > (neg ? '8' : '7')))) | 
 
 
 
 
 
 | 64 | 
 > | 
                                 return 0x100000000LL; | 
 
 
 
 
 
 | 65 | 
 > | 
                          | 
 
 
 
 
 
 | 66 | 
 > | 
                         ret *= 10; | 
 
 
 
 
 
 | 67 | 
 > | 
                         if (*str >= '0' && *str <= '9') | 
 
 
 
 
 
 | 68 | 
 > | 
                                 ret += *str - '0'; | 
 
 
 
 
 
 | 69 | 
 > | 
                         else | 
 
 
 
 
 
 | 70 | 
 > | 
                                 return 0x100000000LL; | 
 
 
 
 
 
 | 71 | 
 > | 
                 } | 
 
 
 
 
 
 | 72 | 
 > | 
                 if (neg) | 
 
 
 
 
 
 | 73 | 
 > | 
                         ret *= -1; | 
 
 
 
 
 
 | 74 | 
 > | 
                 return ret; | 
 
 
 
 
 
 | 75 | 
 > | 
         } | 
 
 
 
 
 
 | 76 | 
 > | 
         else | 
 
 
 
 
 
 | 77 | 
 > | 
                 return 0x100000000LL; | 
 
 
 
 
 
 
 
 
 
 
 
 | 78 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 | 79 | 
 < | 
 */ | 
 
 
 
 
 
 
 
 
 
 | 79 | 
 > | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 80 | 
   | 
 bool inifile_read(const char* filename, inifile_callback callback) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | 
   | 
 { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | 
   | 
         FILE* fp = fopen(filename, "r"); |