| 54 | } |
| 55 | |
| 56 | static int |
| 57 | app_args_parse(int argc, char **argv) |
| 58 | { |
| 59 | struct option lgopts[] = { |
| 60 | {"help", 0, 0, 'H'}, |
| 61 | {"enable-graph-stats", 0, 0, 'g'}, |
| 62 | }; |
| 63 | int h_present, p_present, s_present, n_args, i; |
| 64 | char *app_name = argv[0]; |
| 65 | int opt, option_index; |
| 66 | |
| 67 | /* Skip EAL input args */ |
| 68 | n_args = argc; |
| 69 | for (i = 0; i < n_args; i++) |
| 70 | if (strcmp(argv[i], "--") == 0) { |
| 71 | argc -= i; |
| 72 | argv += i; |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | if (i == n_args) |
| 77 | return 0; |
| 78 | |
| 79 | /* Parse args */ |
| 80 | h_present = 0; |
| 81 | p_present = 0; |
| 82 | s_present = 0; |
| 83 | |
| 84 | while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index)) != EOF) { |
| 85 | switch (opt) { |
| 86 | case 'h': |
| 87 | if (h_present) { |
| 88 | printf("Error: Multiple -h arguments\n"); |
| 89 | return -1; |
| 90 | } |
| 91 | h_present = 1; |
| 92 | |
| 93 | if (!strlen(optarg)) { |
| 94 | printf("Error: Argument for -h not provided\n"); |
| 95 | return -1; |
| 96 | } |
| 97 | |
| 98 | app.conn.addr = strdup(optarg); |
| 99 | if (app.conn.addr == NULL) { |
| 100 | printf("Error: Not enough memory\n"); |
| 101 | return -1; |
| 102 | } |
| 103 | break; |
| 104 | |
| 105 | case 'p': |
| 106 | if (p_present) { |
| 107 | printf("Error: Multiple -p arguments\n"); |
| 108 | return -1; |
| 109 | } |
| 110 | p_present = 1; |
| 111 | |
| 112 | if (!strlen(optarg)) { |
| 113 | printf("Error: Argument for -p not provided\n"); |