diff --git a/src/emu/emu_args.c b/src/emu/emu_args.c new file mode 100644 index 0000000..77eb1f0 --- /dev/null +++ b/src/emu/emu_args.c @@ -0,0 +1,56 @@ +/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#define _POSIX_C_SOURCE 2 + +#include "emu_args.h" + +#include "common.h" +#include +#include + +static char progname[] = "ovniemu"; + +static void +usage(void) +{ + err("Usage: %s [-c offsetfile] tracedir\n", progname); + err("\n"); + err("Options:\n"); + err(" -c offsetfile Use the given offset file to correct\n"); + err(" the clocks among nodes. It can be\n"); + err(" generated by the ovnisync program\n"); + err("\n"); + err(" tracedir The output trace dir generated by ovni.\n"); + err("\n"); + err("The output PRV files are placed in the tracedir directory.\n"); + + exit(EXIT_FAILURE); +} + +void +emu_args_init(struct emu_args *args, int argc, char *argv[]) +{ + memset(args, 0, sizeof(struct emu_args)); + + int opt; + while ((opt = getopt(argc, argv, "c:l")) != -1) { + switch (opt) { + case 'c': + args->clock_offset_file = optarg; + break; + case 'l': + args->linter_mode = 1; + break; + default: /* '?' */ + usage(); + } + } + + if (optind >= argc) { + err("missing tracedir\n"); + usage(); + } + + args->tracedir = argv[optind]; +} diff --git a/src/emu/emu_args.h b/src/emu/emu_args.h new file mode 100644 index 0000000..7dc17fa --- /dev/null +++ b/src/emu/emu_args.h @@ -0,0 +1,15 @@ +/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#ifndef EMU_ARGS_H +#define EMU_ARGS_H + +struct emu_args { + int linter_mode; + char *clock_offset_file; + char *tracedir; +}; + +void emu_args_init(struct emu_args *args, int argc, char *argv[]); + +#endif /* EMU_ARGS_H */