arguments.c

Thu, 09 Feb 2012 15:56:18 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 09 Feb 2012 15:56:18 +0100
changeset 30
d642fdb6745e
parent 20
43725438ac50
permissions
-rw-r--r--

allow parallel use of -s and -S

     1 /*
     2  * arguments.c
     3  *
     4  *  Created on: 15.09.2011
     5  *      Author: Mike
     6  */
     8 #include "arguments.h"
    10 int checkArgument(const char* arg, const char* expected) {
    11   int len = strlen(expected);
    12   int ret = 0;
    14   if (arg[0] == '-') {
    15     if (arg[1] != '-') {
    16       for (int t = 0 ; t < len ; t++) {
    17         ret |= (strchr(arg, expected[t]) > 0) << t;
    18       }
    19     }
    20   }
    22   return ret;
    23 }
    25 bool registerArgument(int* reg, int mask) {
    26   bool ret = (*reg & mask) > 0;
    27   *reg |= mask;
    28   return ret;
    29 }
    31 bool checkParamOpt(int* paropt) {
    32   bool ret = *paropt == 0;
    33   *paropt = 1;
    34   return ret;
    35 }
    37 void parseCSL(char* csl, string_list_t* list) {
    38   if (csl != NULL) {
    39     char* finder = strtok(csl, ",");
    40     while (finder != NULL) {
    41       add_string(list, finder);
    42       finder = strtok(NULL, ",");
    43     }
    44   }
    45 }

mercurial