check_nt.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /******************************************************************************
  2. *
  3. * CHECK_NT.C
  4. *
  5. * Program: Windows NT plugin for NetSaint
  6. * License: GPL
  7. * Copyright (c) 2000-2002 Yves Rubin (rubiyz@yahoo.com)
  8. *
  9. * Description:
  10. *
  11. * This requires NSClient software to run on NT (http://nsclient.ready2run.nl/)
  12. *
  13. * License Information:
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  28. *
  29. *****************************************************************************/
  30. #include "config.h"
  31. #include "common.h"
  32. #include "netutils.h"
  33. #include "utils.h"
  34. #define CHECK_NONE 0
  35. #define CHECK_CLIENTVERSION 1
  36. #define CHECK_CPULOAD 2
  37. #define CHECK_UPTIME 3
  38. #define CHECK_USEDDISKSPACE 4
  39. #define CHECK_SERVICESTATE 5
  40. #define CHECK_PROCSTATE 6
  41. #define CHECK_MEMUSE 7
  42. #define CHECK_COUNTER 8
  43. #define CHECK_FILEAGE 9
  44. #define MAX_VALUE_LIST 30
  45. #define PORT 1248
  46. char *server_address=NULL;
  47. char *volume_name=NULL;
  48. int server_port=PORT;
  49. char *value_list=NULL;
  50. char *req_password=NULL;
  51. unsigned long lvalue_list[MAX_VALUE_LIST];
  52. unsigned long warning_value=0L;
  53. unsigned long critical_value=0L;
  54. int check_value_list=FALSE;
  55. int check_warning_value=FALSE;
  56. int check_critical_value=FALSE;
  57. int vars_to_check=CHECK_NONE;
  58. int show_all=FALSE;
  59. const char *progname = "check_nt";
  60. int process_arguments(int, char **);
  61. void print_usage(void);
  62. void print_help(void);
  63. void preparelist(char *string);
  64. int main(int argc, char **argv){
  65. int result;
  66. int return_code;
  67. char *send_buffer=NULL;
  68. char recv_buffer[MAX_INPUT_BUFFER];
  69. char *output_message=NULL;
  70. char *temp_buffer=NULL;
  71. char *temp_string=NULL;
  72. char *sep_string=NULL;
  73. char *description=NULL;
  74. double total_disk_space=0;
  75. double free_disk_space=0;
  76. double percent_used_space=0;
  77. double mem_commitLimit=0;
  78. double mem_commitByte=0;
  79. unsigned long current_connections=0;
  80. unsigned long utilization;
  81. unsigned long uptime;
  82. unsigned long cache_hits;
  83. unsigned long cache_buffers;
  84. unsigned long lru_time;
  85. unsigned long age_in_minutes;
  86. double counter_value;
  87. int offset=0;
  88. int updays=0;
  89. int uphours=0;
  90. int upminutes=0;
  91. asprintf(&req_password,"None");
  92. if(process_arguments(argc,argv)==ERROR)
  93. usage("Could not parse arguments\n");
  94. /* initialize alarm signal handling */
  95. signal(SIGALRM,socket_timeout_alarm_handler);
  96. /* set socket timeout */
  97. alarm(socket_timeout);
  98. if (vars_to_check==CHECK_CLIENTVERSION) {
  99. asprintf(&send_buffer,strcat(req_password,"&1"));
  100. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  101. if(result!=STATE_OK)
  102. return result;
  103. asprintf(&output_message,recv_buffer);
  104. return_code=STATE_OK;
  105. }
  106. else if(vars_to_check==CHECK_CPULOAD){
  107. if (check_value_list==TRUE) {
  108. if (strtolarray(&lvalue_list,value_list,",")==TRUE) {
  109. /* -l parameters is present with only integers */
  110. return_code=STATE_OK;
  111. asprintf(&temp_string,"CPU Load");
  112. while (lvalue_list[0+offset]>0 && lvalue_list[0+offset]<=17280 &&
  113. lvalue_list[1+offset]>=0 && lvalue_list[1+offset]<=100 &&
  114. lvalue_list[2+offset]>=0 && lvalue_list[2+offset]<=100) {
  115. /* loop until one of the parameters is wrong or not present */
  116. /* Send request and retrieve data */
  117. asprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
  118. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  119. if(result!=STATE_OK)
  120. return result;
  121. if (!strncmp(recv_buffer,"ERROR",5)) {
  122. printf("NSClient - %s\n",recv_buffer);
  123. exit(STATE_UNKNOWN);
  124. }
  125. utilization=strtoul(recv_buffer,NULL,10);
  126. /* Check if any of the request is in a warning or critical state */
  127. if(utilization >= lvalue_list[2+offset])
  128. return_code=STATE_CRITICAL;
  129. else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
  130. return_code=STATE_WARNING;
  131. asprintf(&output_message," %lu%% (%lu min average)", utilization, lvalue_list[0+offset]);
  132. asprintf(&temp_string,"%s%s",temp_string,output_message);
  133. offset+=3; /* move across the array */
  134. }
  135. if (strlen(temp_string)>10) {
  136. /* we had at least on loop */
  137. asprintf(&output_message,"%s",temp_string);
  138. }
  139. else
  140. asprintf(&output_message,"%s","not enough values for -l parameters");
  141. } else
  142. asprintf(&output_message,"wrong -l parameter.");
  143. } else
  144. asprintf(&output_message,"missing -l parameters");
  145. }
  146. else if(vars_to_check==CHECK_UPTIME){
  147. asprintf(&send_buffer,strcat(req_password,"&3"));
  148. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  149. if(result!=STATE_OK)
  150. return result;
  151. if (!strncmp(recv_buffer,"ERROR",5)) {
  152. printf("NSClient - %s\n",recv_buffer);
  153. exit(STATE_UNKNOWN);
  154. }
  155. uptime=strtoul(recv_buffer,NULL,10);
  156. updays = uptime / 86400;
  157. uphours = (uptime % 86400) / 3600;
  158. upminutes = ((uptime % 86400) % 3600) / 60;
  159. asprintf(&output_message,"System Uptime : %u day(s) %u hour(s) %u minute(s)",updays,uphours, upminutes);
  160. return_code=STATE_OK;
  161. }
  162. else if(vars_to_check==CHECK_USEDDISKSPACE){
  163. return_code=STATE_UNKNOWN;
  164. if (check_value_list==TRUE) {
  165. if (strlen(value_list)==1) {
  166. asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
  167. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  168. if(result!=STATE_OK)
  169. return result;
  170. if (!strncmp(recv_buffer,"ERROR",5)) {
  171. printf("NSClient - %s\n",recv_buffer);
  172. exit(STATE_UNKNOWN);
  173. }
  174. free_disk_space=atof(strtok(recv_buffer,"&"));
  175. total_disk_space=atof(strtok(NULL,"&"));
  176. percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
  177. if (free_disk_space>=0) {
  178. asprintf(&temp_string,"%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)",
  179. value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space,
  180. free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
  181. if(check_critical_value==TRUE && percent_used_space >= critical_value)
  182. return_code=STATE_CRITICAL;
  183. else if (check_warning_value==TRUE && percent_used_space >= warning_value)
  184. return_code=STATE_WARNING;
  185. else
  186. return_code=STATE_OK;
  187. asprintf(&output_message,"%s",temp_string);
  188. }
  189. else {
  190. asprintf(&output_message,"Free disk space : Invalid drive ");
  191. return_code=STATE_UNKNOWN;
  192. }
  193. }
  194. else
  195. asprintf(&output_message,"wrong -l argument");
  196. } else
  197. asprintf(&output_message,"missing -l parameters");
  198. }
  199. else if(vars_to_check==CHECK_SERVICESTATE || vars_to_check==CHECK_PROCSTATE){
  200. if (check_value_list==TRUE) {
  201. preparelist(value_list); /* replace , between services with & to send the request */
  202. asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
  203. (show_all==TRUE)?"ShowAll":"ShowFail",value_list);
  204. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  205. if(result!=STATE_OK)
  206. return result;
  207. if (!strncmp(recv_buffer,"ERROR",5)) {
  208. printf("NSClient - %s\n",recv_buffer);
  209. exit(STATE_UNKNOWN);
  210. }
  211. return_code=atoi(strtok(recv_buffer,"&"));
  212. temp_string=strtok(NULL,"&");
  213. asprintf(&output_message, "%s",temp_string);
  214. }
  215. else
  216. asprintf(&output_message,"No service/process specified");
  217. }
  218. else if(vars_to_check==CHECK_MEMUSE) {
  219. asprintf(&send_buffer,"%s&7", req_password);
  220. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  221. if (result!=STATE_OK)
  222. return result;
  223. if (!strncmp(recv_buffer,"ERROR",5)) {
  224. printf("NSClient - %s\n",recv_buffer);
  225. exit(STATE_UNKNOWN);
  226. }
  227. mem_commitLimit=atof(strtok(recv_buffer,"&"));
  228. mem_commitByte=atof(strtok(NULL,"&"));
  229. percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
  230. asprintf(&output_message,"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)",
  231. mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space,
  232. (mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
  233. if(check_critical_value==TRUE && percent_used_space >= critical_value)
  234. return_code=STATE_CRITICAL;
  235. else if (check_warning_value==TRUE && percent_used_space >= warning_value)
  236. return_code=STATE_WARNING;
  237. else
  238. return_code=STATE_OK;
  239. }
  240. else if(vars_to_check==CHECK_COUNTER) {
  241. if (check_value_list==TRUE) {
  242. preparelist(value_list); /* replace , between services with & to send the request */
  243. asprintf(&send_buffer,"%s&8&%s", req_password,value_list);
  244. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  245. if (result!=STATE_OK)
  246. return result;
  247. if (!strncmp(recv_buffer,"ERROR",5)) {
  248. printf("NSClient - %s\n",recv_buffer);
  249. exit(STATE_UNKNOWN);
  250. }
  251. strtok(value_list,"&"); /* burn the first parameters */
  252. description = strtok(NULL,"&");
  253. counter_value = atof(recv_buffer);
  254. if (description == NULL)
  255. asprintf(&output_message, "%.f", counter_value);
  256. else
  257. asprintf(&output_message, description, counter_value);
  258. if (critical_value > warning_value) {
  259. /* Normal thresholds */
  260. if(check_critical_value==TRUE && counter_value >= critical_value)
  261. return_code=STATE_CRITICAL;
  262. else if (check_warning_value==TRUE && counter_value >= warning_value)
  263. return_code=STATE_WARNING;
  264. else
  265. return_code=STATE_OK;
  266. }
  267. else {
  268. /* inverse thresholds */
  269. if(check_critical_value==TRUE && counter_value <= critical_value)
  270. return_code=STATE_CRITICAL;
  271. else if (check_warning_value==TRUE && counter_value <= warning_value)
  272. return_code=STATE_WARNING;
  273. else
  274. return_code=STATE_OK;
  275. }
  276. }
  277. else {
  278. asprintf(&output_message,"No counter specified");
  279. result=STATE_UNKNOWN;
  280. }
  281. }
  282. else if(vars_to_check==CHECK_FILEAGE) {
  283. if (check_value_list==TRUE) {
  284. preparelist(value_list); /* replace , between services with & to send the request */
  285. asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
  286. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  287. if (result!=STATE_OK)
  288. return result;
  289. if (!strncmp(recv_buffer,"ERROR",5)) {
  290. printf("NSClient - %s\n",recv_buffer);
  291. exit(STATE_UNKNOWN);
  292. }
  293. age_in_minutes = atoi(strtok(recv_buffer,"&"));
  294. description = strtok(NULL,"&");
  295. asprintf(&output_message, description);
  296. if (critical_value > warning_value) {
  297. /* Normal thresholds */
  298. if(check_critical_value==TRUE && age_in_minutes >= critical_value)
  299. return_code=STATE_CRITICAL;
  300. else if (check_warning_value==TRUE && age_in_minutes >= warning_value)
  301. return_code=STATE_WARNING;
  302. else
  303. return_code=STATE_OK;
  304. }
  305. else {
  306. /* inverse thresholds */
  307. if(check_critical_value==TRUE && age_in_minutes <= critical_value)
  308. return_code=STATE_CRITICAL;
  309. else if (check_warning_value==TRUE && age_in_minutes <= warning_value)
  310. return_code=STATE_WARNING;
  311. else
  312. return_code=STATE_OK;
  313. }
  314. }
  315. else {
  316. asprintf(&output_message,"No file specified");
  317. result=STATE_UNKNOWN;
  318. }
  319. }
  320. /* reset timeout */
  321. alarm(0);
  322. printf("%s\n",output_message);
  323. return return_code;
  324. }
  325. /* process command-line arguments */
  326. int process_arguments(int argc, char **argv){
  327. int c;
  328. int option_index = 0;
  329. static struct option long_options[] =
  330. {
  331. {"port", required_argument,0,'p'},
  332. {"timeout", required_argument,0,'t'},
  333. {"critical", required_argument,0,'c'},
  334. {"warning", required_argument,0,'w'},
  335. {"variable", required_argument,0,'v'},
  336. {"hostname", required_argument,0,'H'},
  337. {"version", no_argument, 0,'V'},
  338. {"help", no_argument, 0,'h'},
  339. {0,0,0,0}
  340. };
  341. /* no options were supplied */
  342. if(argc<2) return ERROR;
  343. /* backwards compatibility */
  344. if (! is_option(argv[1])) {
  345. server_address=argv[1];
  346. argv[1]=argv[0];
  347. argv=&argv[1];
  348. argc--;
  349. }
  350. for (c=1;c<argc;c++) {
  351. if(strcmp("-to",argv[c])==0)
  352. strcpy(argv[c],"-t");
  353. else if (strcmp("-wv",argv[c])==0)
  354. strcpy(argv[c],"-w");
  355. else if (strcmp("-cv",argv[c])==0)
  356. strcpy(argv[c],"-c");
  357. }
  358. while (1){
  359. c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:",long_options,&option_index);
  360. if (c==-1||c==EOF||c==1)
  361. break;
  362. switch (c)
  363. {
  364. case '?': /* print short usage statement if args not parsable */
  365. printf("%s: Unknown argument: %s\n\n",progname,optarg);
  366. print_usage();
  367. exit(STATE_UNKNOWN);
  368. case 'h': /* help */
  369. print_help();
  370. exit(STATE_OK);
  371. case 'V': /* version */
  372. print_revision(progname,"$Revision$");
  373. exit(STATE_OK);
  374. case 'H': /* hostname */
  375. server_address=optarg;
  376. break;
  377. case 's': /* password */
  378. asprintf(&req_password,optarg);
  379. break;
  380. case 'p': /* port */
  381. if (is_intnonneg(optarg))
  382. server_port=atoi(optarg);
  383. else
  384. terminate(STATE_UNKNOWN,"Server port an integer (seconds)\nType '%s -h' for additional help\n",progname);
  385. break;
  386. case 'v':
  387. if(strlen(optarg)<4)
  388. return ERROR;
  389. if(!strcmp(optarg,"CLIENTVERSION"))
  390. vars_to_check=CHECK_CLIENTVERSION;
  391. else if(!strcmp(optarg,"CPULOAD"))
  392. vars_to_check=CHECK_CPULOAD;
  393. else if(!strcmp(optarg,"UPTIME"))
  394. vars_to_check=CHECK_UPTIME;
  395. else if(!strcmp(optarg,"USEDDISKSPACE"))
  396. vars_to_check=CHECK_USEDDISKSPACE;
  397. else if(!strcmp(optarg,"SERVICESTATE"))
  398. vars_to_check=CHECK_SERVICESTATE;
  399. else if(!strcmp(optarg,"PROCSTATE"))
  400. vars_to_check=CHECK_PROCSTATE;
  401. else if(!strcmp(optarg,"MEMUSE"))
  402. vars_to_check=CHECK_MEMUSE;
  403. else if(!strcmp(optarg,"COUNTER"))
  404. vars_to_check=CHECK_COUNTER;
  405. else if(!strcmp(optarg,"FILEAGE"))
  406. vars_to_check=CHECK_FILEAGE;
  407. else
  408. return ERROR;
  409. break;
  410. case 'l': /* value list */
  411. asprintf(&value_list,"%s",optarg);
  412. check_value_list=TRUE;
  413. break;
  414. case 'w': /* warning threshold */
  415. warning_value=strtoul(optarg,NULL,10);
  416. check_warning_value=TRUE;
  417. break;
  418. case 'c': /* critical threshold */
  419. critical_value=strtoul(optarg,NULL,10);
  420. check_critical_value=TRUE;
  421. break;
  422. case 'd': /* Display select for services */
  423. if (!strcmp(optarg,"SHOWALL"))
  424. show_all = TRUE;
  425. break;
  426. case 't': /* timeout */
  427. socket_timeout=atoi(optarg);
  428. if(socket_timeout<=0)
  429. return ERROR;
  430. }
  431. }
  432. if (vars_to_check==CHECK_NONE)
  433. return ERROR;
  434. return OK;
  435. }
  436. void print_usage(void)
  437. {
  438. printf("Usage: %s -H host -v variable [-p port] [-w warning] [-c critical] [-l params] [-d SHOWALL] [-t timeout]\n",progname);
  439. }
  440. void print_help(void)
  441. {
  442. print_revision(progname,"$Revision$");
  443. printf
  444. ("Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n\n"
  445. "This plugin attempts to contact the NSClient service running on a Windows NT/2000/XP server to\n"
  446. "gather the requested system information.\n\n");
  447. print_usage();
  448. printf
  449. ("\nOptions:\n"
  450. "-H, --hostname=HOST\n"
  451. " Name of the host to check\n"
  452. "-p, --port=INTEGER\n"
  453. " Optional port number (default: %d)\n"
  454. "-s <password>\n"
  455. " Password needed for the request\n"
  456. "-v, --variable=STRING\n"
  457. " Variable to check. Valid variables are:\n"
  458. " CLIENTVERSION = Get the NSClient version\n"
  459. " CPULOAD = Average CPU load on last x minutes. Request a -l parameter with the following syntax:\n"
  460. " -l <minutes range>,<warning threshold>,<critical threshold>. <minute range> should be less than 24*60.\n"
  461. " Thresholds are percentage and up to 10 requests can be done in one shot. ie: -l 60,90,95,120,90,95\n"
  462. " UPTIME = Get the uptime of the machine. No specific parameters. No warning or critical threshold\n"
  463. " USEDDISKSPACE = Size and percentage of disk use. Request a -l parameter containing the drive letter only.\n"
  464. " Warning and critical thresholds can be specified with -w and -c.\n"
  465. " MEMUSE = Memory use. Warning and critical thresholds can be specified with -w and -c.\n"
  466. " SERVICESTATE = Check the state of one or several services. Request a -l parameters with the following syntax:\n"
  467. " -l <service1>,<service2>,<service3>,... You can specify -d SHOWALL in case you want to see working services\n"
  468. " in the returned string.\n"
  469. " PROCSTATE = Check if one or several process are running. Same syntax as SERVICESTATE.\n"
  470. " COUNTER = Check any performance counter of Windows NT/2000. Request a -l parameters with the following syntax:\n"
  471. " -l \"\\\\<performance object>\\\\counter\",\"<description>\" The <description> parameter is optional and \n"
  472. " is given to a printf output command which require a float parameters. Some examples:\n"
  473. " \"Paging file usage is %%.2f %%%%\" or \"%%.f %%%% paging file used.\"\n"
  474. " -w, --warning=INTEGER\n"
  475. " Threshold which will result in a warning status\n"
  476. " -c, --critical=INTEGER\n"
  477. " Threshold which will result in a critical status\n"
  478. " -t, --timeout=INTEGER\n"
  479. " Seconds before connection attempt times out (default: %d)\n"
  480. "-h, --help\n"
  481. " Print this help screen\n"
  482. "-V, --version\n"
  483. " Print version information\n\n"
  484. "Notes:\n"
  485. " - The NSClient service should be running on the server to get any information\n"
  486. " (http://nsclient.ready2run.nl).\n"
  487. " - Critical thresholds should be lower than warning thresholds\n", PORT, DEFAULT_SOCKET_TIMEOUT);
  488. }
  489. int strtolarray(unsigned long *array, char *string, char *delim) {
  490. /* split a <delim> delimited string into a long array */
  491. int idx=0;
  492. char *t1;
  493. for (idx=0;idx<MAX_VALUE_LIST;idx++)
  494. array[idx]=-1;
  495. idx=0;
  496. for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
  497. if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
  498. array[idx]=strtoul(t1,NULL,10);
  499. idx++;
  500. } else
  501. return FALSE;
  502. }
  503. return TRUE;
  504. }
  505. void preparelist(char *string) {
  506. /* Replace all , with & which is the delimiter for the request */
  507. int i;
  508. for (i = 0; i < strlen(string); i++)
  509. if (string[i] == ',') {
  510. string[i]='&';
  511. }
  512. }