MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_sys.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_sys.h : system utility 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_sys.h
18 * @brief MRTKLIB System Module — OS/filesystem utility functions.
19 *
20 * This header provides system-level utility functions for command
21 * execution, file path expansion, directory creation, path keyword
22 * replacement, string-to-number conversion, and file decompression,
23 * extracted from rtkcmn.c with zero algorithmic changes.
24 *
25 * @note Functions declared here are implemented in mrtk_sys.c.
26 */
27#ifndef MRTK_SYS_H
28#define MRTK_SYS_H
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include "mrtklib/mrtk_time.h"
35
36/*============================================================================
37 * String Conversion Functions
38 *===========================================================================*/
39
40/**
41 * @brief Convert substring in string to number.
42 * @param[in] s String ("... nnn.nnn ...")
43 * @param[in] i Substring position
44 * @param[in] n Substring width
45 * @return Converted number (0.0 on error)
46 */
47double str2num(const char* s, int i, int n);
48
49/*============================================================================
50 * Command / Path Functions
51 *===========================================================================*/
52
53/**
54 * @brief Execute command line by operating system shell.
55 * @param[in] cmd Command line string
56 * @return Execution status (0:ok, >0:error)
57 */
58int execcmd(const char* cmd);
59
60/**
61 * @brief Expand file path with wild-card (*) in file.
62 * @param[in] path File path to expand (case insensitive)
63 * @param[out] paths Expanded file paths
64 * @param[in] nmax Max number of expanded file paths
65 * @return Number of expanded file paths
66 * @note The order of expanded files is alphabetical order
67 */
68int expath(const char* path, char* paths[], int nmax);
69
70/**
71 * @brief Create directory if not exists (recursively).
72 * @param[in] path File path to be saved
73 */
74void createdir(const char* path);
75
76/**
77 * @brief Replace keywords in file path with date, time, rover and base
78 * station id.
79 * @param[in] path File path with keywords (see notes)
80 * @param[out] rpath File path with keywords replaced
81 * @param[in] time Time (GPST) (time.time==0: not replaced)
82 * @param[in] rov Rover id string ("": not replaced)
83 * @param[in] base Base station id string ("": not replaced)
84 * @return Status (1:keywords replaced, 0:no valid keyword, -1:no valid time)
85 * @note Keywords: %Y(yyyy), %y(yy), %m(mm), %d(dd), %h(hh), %M(mm),
86 * %S(ss), %n(ddd), %W(wwww), %D(d), %H(h), %ha(hh), %hb(hh),
87 * %hc(hh), %t(mm), %r(rover), %b(base)
88 */
89int reppath(const char* path, char* rpath, gtime_t time, const char* rov, const char* base);
90
91/**
92 * @brief Replace keywords in file path and generate multiple paths.
93 * @param[in] path File path with keywords
94 * @param[out] rpath File paths with keywords replaced
95 * @param[in] nmax Max number of output file paths
96 * @param[in] ts Time start (GPST)
97 * @param[in] te Time end (GPST)
98 * @param[in] rov Rover id string ("": not replaced)
99 * @param[in] base Base station id string ("": not replaced)
100 * @return Number of replaced file paths
101 */
102int reppaths(const char* path, char* rpath[], int nmax, gtime_t ts, gtime_t te, const char* rov, const char* base);
103
104/*============================================================================
105 * File Compression Functions
106 *===========================================================================*/
107
108/**
109 * @brief Uncompress file (gzip/zip/tar/Hatanaka).
110 * @param[in] file Input file
111 * @param[out] uncfile Uncompressed file path
112 * @return Status (-1:error, 0:not compressed file, 1:uncompress completed)
113 * @note Creates uncompressed file in temporary directory.
114 * gzip, tar and crx2rnx commands must be installed.
115 */
116int rtk_uncompress(const char* file, char* uncfile);
117
118#ifdef __cplusplus
119}
120#endif
121
122#endif /* MRTK_SYS_H */
int expath(const char *path, char *paths[], int nmax)
Expand file path with wild-card (*) in file.
Definition mrtk_sys.c:96
int rtk_uncompress(const char *file, char *uncfile)
Uncompress file (gzip/zip/tar/Hatanaka).
Definition mrtk_sys.c:367
int execcmd(const char *cmd)
Execute command line by operating system shell.
Definition mrtk_sys.c:83
void createdir(const char *path)
Create directory if not exists (recursively).
Definition mrtk_sys.c:187
int reppath(const char *path, char *rpath, gtime_t time, const char *rov, const char *base)
Replace keywords in file path with date, time, rover and base station id.
Definition mrtk_sys.c:248
double str2num(const char *s, int i, int n)
Convert substring in string to number.
Definition mrtk_sys.c:60
int reppaths(const char *path, char *rpath[], int nmax, gtime_t ts, gtime_t te, const char *rov, const char *base)
Replace keywords in file path and generate multiple paths.
Definition mrtk_sys.c:321
MRTKLIB Time Module — GNSS time types and conversion functions.
GNSS time representation.
Definition mrtk_time.h:49