Changeset 13123
- Timestamp:
- 10/22/09 00:03:42 (1 month ago)
- Files:
-
- src/router/shared/Makefile (modified) (1 diff)
- src/router/shared/utils.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/router/shared/Makefile
r13116 r13123 29 29 30 30 #CFLAGS += -g -DDEBUG 31 CFLAGS += -f pic31 CFLAGS += -fPIC 32 32 LDFLAGS += -L. 33 33 OBJS := nvparse.o utils.o linux_osl.o src/router/shared/utils.c
r12535 r13123 94 94 int cpu_plltype(void) 95 95 { 96 if (nvram_match("DD_BOARD", "Buffalo WHR-G54S") ||//97 nvram_match("DD_BOARD", "Buffalo WHR-HP-G54") ||//98 nvram_match("DD_BOARD", "Buffalo AS-A100") ||//99 nvram_match("DD_BOARD", "Buffalo WHR-HP-G54DD"))//100 return 0;101 96 if (nvram_match("DD_BOARD", "Buffalo WHR-G54S") || // 97 nvram_match("DD_BOARD", "Buffalo WHR-HP-G54") || // 98 nvram_match("DD_BOARD", "Buffalo AS-A100") || // 99 nvram_match("DD_BOARD", "Buffalo WHR-HP-G54DD")) // 100 return 0; 101 102 102 int cpurev = getcpurev(); 103 103 int cputype = check_hw_type(); … … 128 128 * locate the string "needle" 129 129 */ 130 char * 131 find_in_list(const char *haystack, const char *needle) 130 char *find_in_list(const char *haystack, const char *needle) 132 131 { 133 132 const char *ptr = haystack; … … 142 141 haystack_len = strlen(haystack); 143 142 144 while (*ptr != 0 && ptr < &haystack[haystack_len]) 145 { 143 while (*ptr != 0 && ptr < &haystack[haystack_len]) { 146 144 /* consume leading spaces */ 147 145 ptr += strspn(ptr, " "); … … 151 149 152 150 if ((needle_len == len) && (!strncmp(needle, ptr, len))) 153 return (char *)ptr;151 return (char *)ptr; 154 152 155 153 ptr += len; … … 157 155 return NULL; 158 156 } 159 160 157 161 158 /** … … 169 166 * @return error code 170 167 */ 171 int 172 remove_from_list(const char *name, char *list, int listsize) 168 int remove_from_list(const char *name, char *list, int listsize) 173 169 { 174 170 int listlen = 0; … … 188 184 189 185 /* last item in list? */ 190 if (occurrence[namelen] == 0) 191 { 186 if (occurrence[namelen] == 0) { 192 187 /* only item in list? */ 193 188 if (occurrence != list) 194 189 occurrence--; 195 190 occurrence[0] = 0; 196 } 197 else if (occurrence[namelen] == ' ') 198 { 199 strncpy(occurrence, &occurrence[namelen+1 /* space */], 200 strlen(&occurrence[namelen+1 /* space */]) +1 /* terminate */); 191 } else if (occurrence[namelen] == ' ') { 192 strncpy(occurrence, &occurrence[namelen + 1 /* space */ ], 193 strlen(&occurrence[namelen + 1 /* space */ ]) + 194 1 /* terminate */ ); 201 195 } 202 196 … … 217 211 * @return error code 218 212 */ 219 int 220 add_to_list(const char *name, char *list, int listsize) 213 int add_to_list(const char *name, char *list, int listsize) 221 214 { 222 215 int listlen = 0; … … 233 226 return 0; 234 227 235 if (listsize <= listlen + namelen + 1 /* space */ + 1 /* NULL */)228 if (listsize <= listlen + namelen + 1 /* space */ + 1 /* NULL */ ) 236 229 return EMSGSIZE; 237 230 238 231 /* add a space if the list isn't empty and it doesn't already have space */ 239 if (list[0] != 0 && list[listlen-1] != ' ') 240 { 232 if (list[0] != 0 && list[listlen - 1] != ' ') { 241 233 list[listlen++] = 0x20; 242 234 } 243 235 244 strncpy(&list[listlen], name, namelen + 1 /* terminate */ );236 strncpy(&list[listlen], name, namelen + 1 /* terminate */ ); 245 237 246 238 return 0; … … 415 407 } 416 408 if (!match) { 417 snprintf(dns_list-> 418 dns_server[dns_list->num_servers], 419 sizeof(dns_list->dns_server 420 [dns_list->num_servers]), "%s", 409 snprintf(dns_list->dns_server 410 [dns_list->num_servers], 411 sizeof(dns_list-> 412 dns_server[dns_list-> 413 num_servers]), "%s", 421 414 word); 422 415 dns_list->num_servers++; … … 439 432 if (strlen(nvram_safe_get(altdnsvar)) > 0) { 440 433 snprintf(dns_list->dns_server[dns_list->num_servers], 441 sizeof(dns_list-> 442 dns_server[dns_list->num_servers]),443 "%s",nvram_safe_get(altdnsvar));434 sizeof(dns_list->dns_server 435 [dns_list->num_servers]), "%s", 436 nvram_safe_get(altdnsvar)); 444 437 dns_list->num_servers++; 445 438 }
