Chinaunix首页 | 论坛 | 博客

分类: LINUX

2011-10-01 15:56:50

<---------_____________
mu_run_test (test_commands_sorted);/*___----->/src/init.c*/

1649 const char *
1650 test_commands_sorted()
1651 {
1652   int prev_idx = 0, next_idx = 1;
1653   int command_count = countof (commands) - 1;/*  1 ______----->/src/wget.h commands 数据结构定义在  2________--------->/src/init.c*/
1654   int cmp = 0;
1655   while (next_idx <= command_count)
1656     {
1657       cmp = strcasecmp (commands[prev_idx].name, commands[next_idx].name);
1658       if (cmp > 0)
1659         {
1660           mu_assert ("FAILED", false);  /* 3____------>/src/test.h*/
1661           break;
1662         }
1663       else
1664         {
1665           prev_idx ++;
1666           next_idx ++;
1667         }
1668     }
1669   return NULL;
1670 }
1   _________-------->
/*src/wget.h*/
#define countof(array) (sizeof (array) /sizeof ((array) [0]))
2___________--------->实在太多了!!!!!!!想想当初自己用wget xxx.xxx.xxx.xxx/xxx就觉得很舒坦,现在知道支持很多命令的,而且适合opotion结构体是相对应的。*/
111 static const struct {
112   const char *name;
113   void *place;
114   bool (*action) (const char *, const char *, void *);
115 } commands[] = {
116   /* KEEP THIS LIST ALPHABETICALLY SORTED */
117   { "accept",           &opt.accepts,           cmd_vector },
118   { "addhostdir",       &opt.add_hostdir,       cmd_boolean },
119   { "adjustextension",  &opt.adjust_extension,  cmd_boolean },
120   { "alwaysrest",       &opt.always_rest,       cmd_boolean }, /* deprecated */
121   { "askpassword",      &opt.ask_passwd,        cmd_boolean },
122   { "authnochallenge",  &opt.auth_without_challenge,
123                                                 cmd_boolean },
124   { "background",       &opt.background,        cmd_boolean },
125   { "backupconverted",  &opt.backup_converted,  cmd_boolean },
126   { "backups",          &opt.backups,           cmd_number },
127   { "base",             &opt.base_href,         cmd_string },
128   { "bindaddress",      &opt.bind_address,      cmd_string },
129 #ifdef HAVE_SSL
130   { "cacertificate",    &opt.ca_cert,           cmd_file },
131 #endif
132   { "cache",            &opt.allow_cache,       cmd_boolean },
133 #ifdef HAVE_SSL
134   { "cadirectory",      &opt.ca_directory,      cmd_directory },
135   { "certificate",      &opt.cert_file,         cmd_file },
136   { "certificatetype",  &opt.cert_type,         cmd_cert_type },
137   { "checkcertificate", &opt.check_cert,        cmd_boolean },
138 #endif
139   { "chooseconfig",     &opt.choose_config,     cmd_file },
140   { "connecttimeout",   &opt.connect_timeout,   cmd_time },
141   { "contentdisposition", &opt.content_disposition, cmd_boolean },
142   { "continue",         &opt.always_rest,       cmd_boolean },
143   { "convertlinks",     &opt.convert_links,     cmd_boolean },
144   { "cookies",          &opt.cookies,           cmd_boolean },
. . . . . .
261   { "useragent",        NULL,                   cmd_spec_useragent },
262   { "useservertimestamps", &opt.useservertimestamps, cmd_boolean },
263   { "verbose",          NULL,                   cmd_spec_verbose },
264   { "wait",             &opt.wait,              cmd_time },
265   { "waitretry",        &opt.waitretry,         cmd_time },
266 #ifdef USE_WATT32
267   { "wdebug",           &opt.wdebug,            cmd_boolean },
268 #endif
269 };
/*此段函数只是保证,command为这个顺序*/
这里再强调下
  3  ____------>
#define mu_insert(message, test) do{ if (!(test)) return message; } while(0);
/*test为0时才会打印错误信息*/
阅读(931) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~