# #
#############################################################################*/
+#include <getopt.h>
+#include <stdio.h>
+
+#include "main.h"
+
+static int parse_argv(int argc, char* argv[], struct fireperf_config* conf) {
+ static struct option long_options[] = {
+ {"client", required_argument, 0, 'c'},
+ {"server", no_argument, 0, 's'},
+ {0, 0, 0, 0},
+ };
+
+ int option_index = 0;
+ int done = 0;
+
+ while (!done) {
+ int c = getopt_long(argc, argv, "c:s", long_options, &option_index);
+
+ // End
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 0:
+ if (long_options[option_index].flag != 0)
+ break;
+
+ printf("option %s", long_options[option_index].name);
+
+ if (optarg)
+ printf(" with arg: %s", optarg);
+
+ printf("\n");
+ break;
+
+ case '?':
+ // getopt_long already printed the error message
+ return 1;
+
+ case 'c':
+ conf->mode = FIREPERF_MODE_CLIENT;
+ break;
+
+ case 's':
+ conf->mode = FIREPERF_MODE_SERVER;
+ break;
+
+ default:
+ done = 1;
+ break;
+ }
+ }
+
+ return 0;
+}
+
int main(int argc, char* argv[]) {
+ struct fireperf_config conf;
+ int r;
+
+ // Parse command line
+ r = parse_argv(argc, argv, &conf);
+ if (r)
+ return r;
+
+ // Check if a mode has been selected
+ if (!conf.mode) {
+ fprintf(stderr, "No mode selected\n");
+ return 2;
+ }
+
return 0;
}
--- /dev/null
+/*#############################################################################
+# #
+# fireperf - A network benchmarking tool #
+# Copyright (C) 2021 IPFire Development Team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+struct fireperf_config {
+ enum {
+ FIREPERF_MODE_NONE = 0,
+ FIREPERF_MODE_CLIENT,
+ FIREPERF_MODE_SERVER,
+ } mode;
+};