MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_cli.c
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_cli.c : shared CLI helpers for mrtk subcommands
3 *
4 * Copyright (C) 2026, MRTKLIB Contributors, All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-2-Clause
7 *-----------------------------------------------------------------------------*/
8#include "mrtklib/mrtk_cli.h"
9
10#include <string.h>
11
12void mrtk_normalize_args(int argc, char** argv, const mrtk_optmap_t* map) {
13 int i, j;
14 if (!map || !argv) {
15 return;
16 }
17 for (i = 1; i < argc; i++) {
18 if (!argv[i]) {
19 continue;
20 }
21 for (j = 0; map[j].long_opt; j++) {
22 if (strcmp(argv[i], map[j].long_opt) == 0) {
23 argv[i] = (char*)map[j].short_opt;
24 break;
25 }
26 }
27 }
28}
29
30int mrtk_is_help_flag(const char* arg) {
31 if (!arg) {
32 return 0;
33 }
34 return strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0;
35}
void mrtk_normalize_args(int argc, char **argv, const mrtk_optmap_t *map)
Translate --long flags to their -short aliases in argv (in place).
Definition mrtk_cli.c:12
int mrtk_is_help_flag(const char *arg)
Returns 1 if arg is a generic help flag (-h or --help), else 0.
Definition mrtk_cli.c:30
Long-option to short-option alias entry.
Definition mrtk_cli.h:26
const char * long_opt
Definition mrtk_cli.h:27