hamnet70/impl/src/options.c
Thomas Kolb 2e91fd7c42 Apply free software+documentation licenses
All code is now licensed under GPLv3+. The documentation is licensed under
CC BY-SA 4.0.

This is now officially free software! \o/
2024-08-23 11:53:40 +02:00

44 lines
727 B
C

/*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Copyright (C) 2024 Thomas Kolb
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include "options.h"
static uint32_t m_flags;
int options_parse(int argc, char **argv)
{
int opt;
int nparsed = 0;
while((opt = getopt(argc, argv, "c")) != -1) {
switch(opt) {
case 'c':
m_flags |= (1 << OPTIONS_FLAG_IS_CENTRAL_NODE);
break;
default:
fprintf(stderr,
"Usage: %s [-c]\n\n"
" -c Makes this node a central node (base station).\n",
argv[0]);
exit(EXIT_FAILURE);
}
nparsed++;
}
return nparsed;
}
bool options_is_flag_set(options_flag_t flag)
{
return (m_flags & (1 << flag)) != 0;
}