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

/*
 * arguments.c
 *
 *  Created on: 15.09.2011
 *      Author: Mike
 */

#include "arguments.h"

int checkArgument(const char* arg, const char* expected) {
  int len = strlen(expected);
  int ret = 0;

  if (arg[0] == '-') {
    if (arg[1] != '-') {
      for (int t = 0 ; t < len ; t++) {
        ret |= (strchr(arg, expected[t]) > 0) << t;
      }
    }
  }

  return ret;
}

bool registerArgument(int* reg, int mask) {
  bool ret = (*reg & mask) > 0;
  *reg |= mask;
  return ret;
}

bool checkParamOpt(int* paropt) {
  bool ret = *paropt == 0;
  *paropt = 1;
  return ret;
}

void parseCSL(char* csl, string_list_t* list) {
  if (csl != NULL) {
    char* finder = strtok(csl, ",");
    while (finder != NULL) {
      add_string(list, finder);
      finder = strtok(NULL, ",");
    }
  }
}

mercurial