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