/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-client.c

changed from using strtok to strsep

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
                                   close() */
52
52
#include <fcntl.h>              /* fcntl(), F_GETFD, F_SETFD,
53
53
                                   FD_CLOEXEC */
54
 
#include <string.h>             /* strtok, strlen(), strcpy(),
 
54
#include <string.h>             /* strsep, strlen(), strcpy(),
55
55
                                   strcat() */
56
56
#include <errno.h>              /* errno */
57
57
#include <argp.h>               /* struct argp_option, struct
248
248
    switch (key) {
249
249
    case 'g':
250
250
      if (arg != NULL){
251
 
        char *p = strtok(arg, ",");
252
 
        do{
 
251
        char *p;
 
252
        while((p = strsep(&arg, ",")) != NULL){
 
253
          if(strcmp(p, "") == 0){
 
254
            continue;
 
255
          }
253
256
          addargument(getplugin(NULL, plugins), p);
254
 
          p = strtok(NULL, ",");
255
 
        } while (p != NULL);
 
257
        }
256
258
      }
257
259
      break;
258
260
    case 'o':
259
261
      if (arg != NULL){
260
 
        char *name = strtok(arg, ":");
261
 
        char *p = strtok(NULL, ":");
262
 
        if(p != NULL){
263
 
          p = strtok(p, ",");
264
 
          do{
 
262
        char *name = strsep(&arg, ":");
 
263
        if(strcmp(name, "") == 0){
 
264
          break;
 
265
        }
 
266
        char *opt = strsep(&arg, ":");
 
267
        if(strcmp(opt, "") == 0){
 
268
          break;
 
269
        }
 
270
        if(opt != NULL){
 
271
          char *p;
 
272
          while((p = strsep(&opt, ",")) != NULL){
 
273
            if(strcmp(p, "") == 0){
 
274
              continue;
 
275
            }
265
276
            addargument(getplugin(name, plugins), p);
266
 
            p = strtok(NULL, ",");
267
 
          } while (p != NULL);
 
277
          }
268
278
        }
269
279
      }
270
280
      break;
328
338
    }
329
339
    plus_argv[0] = argv[0];
330
340
    plus_argv[1] = NULL;
331
 
    arg = strtok(plus_options, delims); /* Get first argument */
332
 
    while(arg != NULL){
 
341
 
 
342
    while((arg = strsep(&plus_options, delims)) != NULL){
333
343
      new_argc++;
334
344
      plus_argv = realloc(plus_argv, sizeof(char *)
335
345
                         * ((unsigned int) new_argc + 1));
340
350
      }
341
351
      plus_argv[new_argc-1] = arg;
342
352
      plus_argv[new_argc] = NULL;
343
 
      arg = strtok(NULL, delims); /* Get next argument */
344
353
    }
 
354
 
345
355
    ret = argp_parse (&argp, new_argc, plus_argv, 0, 0, &plugin_list);
346
356
    if (ret == ARGP_ERR_UNKNOWN){
347
357
      fprintf(stderr, "Unknown error while parsing arguments\n");