MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_sys.c File Reference

MRTKLIB System Module — Implementation. More...

#include "mrtklib/mrtk_sys.h"
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "mrtklib/mrtk_trace.h"
Include dependency graph for mrtk_sys.c:

Go to the source code of this file.

Macros

#define _POSIX_C_SOURCE   199506
#define FILEPATHSEP   '/'

Functions

double str2num (const char *s, int i, int n)
 Convert substring in string to number.
int execcmd (const char *cmd)
 Execute command line by operating system shell.
int expath (const char *path, char *paths[], int nmax)
 Expand file path with wild-card (*) in file.
static int mkdir_r (const char *dir)
void createdir (const char *path)
 Create directory if not exists (recursively).
static int repstr (char *str, const char *pat, const char *rep)
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.
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.
int rtk_uncompress (const char *file, char *uncfile)
 Uncompress file (gzip/zip/tar/Hatanaka).

Detailed Description

MRTKLIB System Module — Implementation.

All functions and static data in this file are cut-and-paste extractions from the legacy rtkcmn.c with zero algorithmic changes.

Definition in file mrtk_sys.c.

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   199506

Definition at line 24 of file mrtk_sys.c.

◆ FILEPATHSEP

#define FILEPATHSEP   '/'

Definition at line 48 of file mrtk_sys.c.

Referenced by createdir(), ftpthread(), mkdir_r(), readbnxt(), readrnxt(), and update_stat().

Function Documentation

◆ createdir()

void createdir ( const char * path)
extern

Create directory if not exists (recursively).

Parameters
[in]pathFile path to be saved

Definition at line 187 of file mrtk_sys.c.

References FILEPATHSEP, mkdir_r(), and tracet().

Referenced by openfile(), openfile_(), and outhead().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execcmd()

int execcmd ( const char * cmd)
extern

Execute command line by operating system shell.

Parameters
[in]cmdCommand line string
Returns
Execution status (0:ok, >0:error)

Definition at line 83 of file mrtk_sys.c.

References trace().

Referenced by ftpthread(), and rtk_uncompress().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expath()

int expath ( const char * path,
char * paths[],
int nmax )
extern

Expand file path with wild-card (*) in file.

Parameters
[in]pathFile path to expand (case insensitive)
[out]pathsExpanded file paths
[in]nmaxMax number of expanded file paths
Returns
Number of expanded file paths
Note
The order of expanded files is alphabetical order

Definition at line 96 of file mrtk_sys.c.

References trace().

Referenced by convrnx_s(), readbnxt(), readdcb(), readfcb(), readisb(), readrnxc(), readrnxt(), readsp3(), readtec(), and sbsreadmsgt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mkdir_r()

int mkdir_r ( const char * dir)
static

Definition at line 156 of file mrtk_sys.c.

References FILEPATHSEP, mkdir_r(), and trace().

Referenced by createdir(), and mkdir_r().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reppath()

int reppath ( const char * path,
char * rpath,
gtime_t time,
const char * rov,
const char * base )
extern

Replace keywords in file path with date, time, rover and base station id.

Parameters
[in]pathFile path with keywords (see notes)
[out]rpathFile path with keywords replaced
[in]timeTime (GPST) (time.time==0: not replaced)
[in]rovRover id string ("": not replaced)
[in]baseBase station id string ("": not replaced)
Returns
Status (1:keywords replaced, 0:no valid keyword, -1:no valid time)
Note
Keywords: Y(yyyy), y(yy), m(mm), d(dd), h(hh), M(mm), S(ss), n(ddd), W(wwww), D(d), H(h), ha(hh), hb(hh), hc(hh), t(mm), r(rover), b(base)

Definition at line 248 of file mrtk_sys.c.

References epoch2time(), repstr(), gtime_t::time, time2epoch(), time2gpst(), and timediff().

Referenced by convrnx_s(), execses(), execses_b(), execses_r(), ftpthread(), openfile_(), postpos(), readpreceph(), reppaths(), rtkopenstat(), swapfile(), swapsolstat(), traceopen(), udbiass(), update_clas(), update_gal_has(), update_qzssl6d(), update_qzssl6e(), update_rtcm(), and update_stat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reppaths()

int reppaths ( const char * path,
char * rpath[],
int nmax,
gtime_t ts,
gtime_t te,
const char * rov,
const char * base )
extern

Replace keywords in file path and generate multiple paths.

Parameters
[in]pathFile path with keywords
[out]rpathFile paths with keywords replaced
[in]nmaxMax number of output file paths
[in]tsTime start (GPST)
[in]teTime end (GPST)
[in]rovRover id string ("": not replaced)
[in]baseBase station id string ("": not replaced)
Returns
Number of replaced file paths

Definition at line 321 of file mrtk_sys.c.

References gpst2time(), reppath(), gtime_t::time, time2gpst(), timeadd(), timediff(), and trace().

Referenced by postpos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ repstr()

int repstr ( char * str,
const char * pat,
const char * rep )
static

Definition at line 201 of file mrtk_sys.c.

Referenced by reppath().

Here is the caller graph for this function:

◆ rtk_uncompress()

int rtk_uncompress ( const char * file,
char * uncfile )
extern

Uncompress file (gzip/zip/tar/Hatanaka).

Parameters
[in]fileInput file
[out]uncfileUncompressed file path
Returns
Status (-1:error, 0:not compressed file, 1:uncompress completed)
Note
Creates uncompressed file in temporary directory. gzip, tar and crx2rnx commands must be installed.

Definition at line 367 of file mrtk_sys.c.

References execcmd(), and trace().

Referenced by ftpthread(), readbnxfile(), and readrnxfile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str2num()

double str2num ( const char * s,
int i,
int n )
extern

Convert substring in string to number.

Parameters
[in]sString ("... nnn.nnn ...")
[in]iSubstring position
[in]nSubstring width
Returns
Converted number (0.0 on error)

Definition at line 60 of file mrtk_sys.c.

Referenced by decode_navh(), decode_obsdata(), decode_obsepoch(), decode_obsh(), readbsnx(), readdcbf(), readionexb(), readionexdcb(), readionexh(), readisbf(), readL2C(), readrnxclk(), readrnxh(), readrnxnavb(), readsp3b(), and readsp3h().

Here is the caller graph for this function: