コード例 #1
0
ファイル: topology_test_th.c プロジェクト: HunterChen/GRAPES
static void cmdline_parse(int argc, char *argv[])
{
  int o;

  while ((o = getopt(argc, argv, "s:p:i:P:I:")) != -1) {
    switch(o) {
      case 'p':
        srv_port = atoi(optarg);
        break;
      case 'i':
        srv_ip = strdup(optarg);
        break;
      case 'P':
        port =  atoi(optarg);
        break;
      case 'I':
        my_addr = iface_addr(optarg);
        break;
      case 's':
        fprefix = strdup(optarg);
        break;
      default:
        fprintf(stderr, "Error: unknown option %c\n", o);

        exit(-1);
    }
  }
}
コード例 #2
0
static int cmdline_parse(int argc, char *argv[])
{
  int o;

  while ((o = getopt(argc, argv, "s:P:I:c:i:p:")) != -1) {
    printf("%c", o);
    if (optarg) printf(" -> %s\n", optarg);
    else printf("\n");
    switch(o) {
      case 'c':
        cloud_conf = strdup(optarg);
        break;
      case 'P':
        port =  atoi(optarg);
        break;
      case 'I':
        my_addr = iface_addr(optarg);
        break;
      case 's':
        fprefix = strdup(optarg);
        break;
      case 'i':
      case 'p':
        fprintf(stderr, "Ignoring option %c, just for compatibility\n", o);
        break;
      default:
        fprintf(stderr, "Error: unknown option %c\n", o);
        return 1;
    }
  }

  return 0;
}
コード例 #3
0
static void cmdline_parse(int argc, char *argv[])
{
  int o;

  while ((o = getopt(argc, argv, "p:i:P:I:ORBbN")) != -1) {
    switch(o) {
      case 'p':
        dst_port = atoi(optarg);
        break;
      case 'i':
        dst_ip = strdup(optarg);
        break;
      case 'P':
        port =  atoi(optarg);
        break;
      case 'I':
        my_addr = iface_addr(optarg);
        break;
      case 'O':
          sig = offer;
          break;
      case 'R':
          sig = request;
          break;
      case 'B':
          sig = sendbmap;
          break;
      case 'b':
          sig = reqbmap;
          break;
     case 'N':
          random_bmap = 1;
          break;
     default:
        fprintf(stderr, "Error: unknown option %c\n", o);

        exit(-1);
    }
  }
}