| 109 | } |
| 110 | |
| 111 | static int readEntry(const char *line, ConfigEntry *entries, int n_entries) { |
| 112 | // Trim at beginning |
| 113 | while (*line == ' ' || *line == '\t') |
| 114 | line++; |
| 115 | |
| 116 | // Ignore comments #1 |
| 117 | if (line[0] == '#') { |
| 118 | // debugPrintf("IGNORE %s\n", line); |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | // Ignore comments #2 |
| 123 | char *p = strchr(line, '#'); |
| 124 | if (p) { |
| 125 | // debugPrintf("IGNORE %s\n", p); |
| 126 | *p = '\0'; |
| 127 | } |
| 128 | |
| 129 | // Get token |
| 130 | p = strchr(line, '='); |
| 131 | if (!p) |
| 132 | return -1; |
| 133 | |
| 134 | // Name of entry |
| 135 | char name[MAX_CONFIG_NAME_LENGTH]; |
| 136 | int len = p - line; |
| 137 | if (len > MAX_CONFIG_NAME_LENGTH - 1) |
| 138 | len = MAX_CONFIG_NAME_LENGTH - 1; |
| 139 | strncpy(name, line, len); |
| 140 | name[len] = '\0'; |
| 141 | |
| 142 | trim(name); |
| 143 | |
| 144 | // debugPrintf("NAME: %s\n", name); |
| 145 | |
| 146 | // String of entry |
| 147 | char *string = p + 1; |
| 148 | |
| 149 | // Trim at beginning |
| 150 | while (*string == ' ' || *string == '\t') |
| 151 | string++; |
| 152 | |
| 153 | // Trim at end |
| 154 | trim(string); |
| 155 | |
| 156 | // debugPrintf("STRING: %s\n", string); |
| 157 | |
| 158 | int i; |
| 159 | for (i = 0; i < n_entries; i++) { |
| 160 | if (strcasecmp(name, entries[i].name) == 0) { |
| 161 | switch (entries[i].type) { |
| 162 | case CONFIG_TYPE_DECIMAL: |
| 163 | *(uint32_t *)entries[i].value = getDecimal(string); |
| 164 | // debugPrintf("VALUE DECIMAL: %d\n", *(uint32_t *)entries[i].value); |
| 165 | break; |
| 166 | |
| 167 | case CONFIG_TYPE_HEXDECIMAL: |
| 168 | *(uint32_t *)entries[i].value = getHexdecimal(string); |
no test coverage detected