Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/networking/libiproute/rt_names.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 13  Line 13 
13  #include "libbb.h"  #include "libbb.h"
14  #include "rt_names.h"  #include "rt_names.h"
15    
16  static void rtnl_tab_initialize(char *file, const char **tab, int size)  /* so far all callers have size == 256 */
17    #define rtnl_tab_initialize(file, tab, size) rtnl_tab_initialize(file, tab)
18    #define size 256
19    static void rtnl_tab_initialize(const char *file, const char **tab, int size)
20  {  {
21   char buf[512];   char *token[2];
22   FILE *fp;   parser_t *parser = config_open2(file, fopen_for_read);
23     while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) {
24   fp = fopen(file, "r");   int id = bb_strtou(token[0], NULL, 0);
25   if (!fp)   if (id < 0 || id > size) {
26   return;   bb_error_msg("database %s is corrupted at line %d",
27   while (fgets(buf, sizeof(buf), fp)) {   file, parser->lineno);
28   char *p = buf;   break;
  int id;  
  char namebuf[512];  
   
  while (*p == ' ' || *p == '\t')  
  p++;  
  if (*p == '#' || *p == '\n' || *p == 0)  
  continue;  
  if (sscanf(p, "0x%x %s\n", &id, namebuf) != 2 &&  
     sscanf(p, "0x%x %s #", &id, namebuf) != 2 &&  
     sscanf(p, "%d %s\n", &id, namebuf) != 2 &&  
     sscanf(p, "%d %s #", &id, namebuf) != 2) {  
  bb_error_msg("database %s is corrupted at %s",  
  file, p);  
  return;  
29   }   }
30     tab[id] = xstrdup(token[1]);
  if (id < 0 || id > size)  
  continue;  
   
  tab[id] = xstrdup(namebuf);  
31   }   }
32   fclose(fp);   config_close(parser);
33  }  }
34    #undef size
35    
36  static const char **rtnl_rtprot_tab; /* [256] */  static const char **rtnl_rtprot_tab; /* [256] */
37    

Legend:
Removed from v.532  
changed lines
  Added in v.816