MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_options.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_options.h : option string processing functions
3 *
4 * Copyright (C) 2026 H.SHIONO (MRTKLIB Project)
5 * Copyright (C) 2023-2025 Cabinet Office, Japan
6 * Copyright (C) 2024-2025 Lighthouse Technology & Consulting Co. Ltd.
7 * Copyright (C) 2023-2025 Japan Aerospace Exploration Agency
8 * Copyright (C) 2023-2025 TOSHIBA ELECTRONIC TECHNOLOGIES CORPORATION
9 * Copyright (C) 2015- Mitsubishi Electric Corp.
10 * Copyright (C) 2014 Geospatial Information Authority of Japan
11 * Copyright (C) 2014 T.SUZUKI
12 * Copyright (C) 2007-2023 T.TAKASU
13 *
14 * SPDX-License-Identifier: BSD-2-Clause
15 *----------------------------------------------------------------------------*/
16/**
17 * @file mrtk_options.h
18 * @brief MRTKLIB Options Module — Configuration option parsing and system
19 * option management.
20 *
21 * This header provides the opt_t type for option table entries, functions
22 * for loading/saving/converting options, and the system options interface
23 * (sysopts, getsysopts, setsysopts, resetsysopts).
24 * Extracted from the legacy options.c / rtklib.h with zero algorithmic changes.
25 *
26 * @note Functions declared here are implemented in mrtk_options.c.
27 */
28#ifndef MRTK_OPTIONS_H
29#define MRTK_OPTIONS_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35#include "mrtklib/mrtk_opt.h"
36
37/*============================================================================
38 * Option Table Entry Type
39 *===========================================================================*/
40
41/**
42 * @brief Option type for configuration file parsing.
43 */
44typedef struct {
45 const char* name; /**< option name */
46 int format; /**< option format (0:int,1:double,2:string,3:enum) */
47 void* var; /**< pointer to option variable */
48 const char* comment; /**< option comment/enum labels/unit */
49} opt_t;
50
51/*============================================================================
52 * Global Variables
53 *===========================================================================*/
54
55/**
56 * @brief System options table.
57 * @note Terminated with an entry where name[0]=='\\0'.
58 */
59extern opt_t sysopts[];
60
61/*============================================================================
62 * Option Functions
63 *===========================================================================*/
64
65/**
66 * @brief Search option record.
67 * @param[in] name Option name
68 * @param[in] opts Options table (terminated with name="")
69 * @return Option record (NULL: not found)
70 */
71opt_t* searchopt(const char* name, const opt_t* opts);
72
73/**
74 * @brief Convert string to option value.
75 * @param[out] opt Option
76 * @param[in] str Option value string
77 * @return Status (1:ok, 0:error)
78 */
79int str2opt(opt_t* opt, const char* str);
80
81/**
82 * @brief Convert option value to string.
83 * @param[in] opt Option
84 * @param[out] str Option value string
85 * @return Length of output string
86 */
87int opt2str(const opt_t* opt, char* str);
88
89/**
90 * @brief Convert option to string (keyword=value # comment).
91 * @param[in] opt Option
92 * @param[out] buff Option string
93 * @return Length of output string
94 */
95int opt2buf(const opt_t* opt, char* buff);
96
97/**
98 * @brief Load options from file.
99 * @param[in] file Options file
100 * @param[in,out] opts Options table (terminated with name="")
101 * @return Status (1:ok, 0:error)
102 */
103int loadopts(const char* file, opt_t* opts);
104
105/**
106 * @brief Save options to file.
107 * @param[in] file Options file
108 * @param[in] mode Write mode ("w":overwrite, "a":append; append is not
109 * supported for a .toml file and returns 0)
110 * @param[in] comment Header comment (NULL: no comment)
111 * @param[in] opts Options table (terminated with name="")
112 * @return Status (1:ok, 0:error)
113 */
114int saveopts(const char* file, const char* mode, const char* comment, const opt_t* opts);
115
116/**
117 * @brief Reset system options to default.
118 */
119void resetsysopts(void);
120
121/**
122 * @brief Get system options.
123 * @param[out] popt Processing options (NULL: no output)
124 * @param[out] sopt Solution options (NULL: no output)
125 * @param[out] fopt File options (NULL: no output)
126 */
127void getsysopts(prcopt_t* popt, solopt_t* sopt, filopt_t* fopt);
128
129/**
130 * @brief Set system options.
131 * @param[in] prcopt Processing options (NULL: default)
132 * @param[in] solopt Solution options (NULL: default)
133 * @param[in] filopt File options (NULL: default)
134 */
135void setsysopts(const prcopt_t* prcopt, const solopt_t* solopt, const filopt_t* filopt);
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif /* MRTK_OPTIONS_H */
MRTKLIB Options Module — Processing and solution option types.
opt_t sysopts[]
System options table.
int loadopts(const char *file, opt_t *opts)
Load options from file.
void getsysopts(prcopt_t *popt, solopt_t *sopt, filopt_t *fopt)
Get system options.
int saveopts(const char *file, const char *mode, const char *comment, const opt_t *opts)
Save options to file.
int opt2str(const opt_t *opt, char *str)
Convert option value to string.
opt_t * searchopt(const char *name, const opt_t *opts)
Search option record.
int opt2buf(const opt_t *opt, char *buff)
Convert option to string (keyword=value # comment).
int str2opt(opt_t *opt, const char *str)
Convert string to option value.
void setsysopts(const prcopt_t *prcopt, const solopt_t *solopt, const filopt_t *filopt)
Set system options.
void resetsysopts(void)
Reset system options to default.
Option type for configuration file parsing.
int format
void * var
const char * name
const char * comment