das2C
das core C utilities (v3)
Data Structures | Macros | Enumerations | Functions
cli.h File Reference

More...

#include <das2/das1.h>
#include <string.h>
#include <stdbool.h>
Include dependency graph for cli.h:

Go to the source code of this file.

Data Structures

struct  DasSelector
 Holds a single data selection query parameter. More...
 
struct  DasOutput
 A basic statement of output is needed to help with output resolution reduction. More...
 

Macros

#define OP_BEG   ".ge."
 Strings to assist with operator comparisons.
 
#define REQUIRED   0x00
 Flags for selector and output defintions.
 
#define DAS_OUT_DISABLE   0x0200
 Use this in nOpts to disable the output be default.
 

Enumerations

enum  das_selfmt
 An enumeration of das selector value types.
 

Functions

const char * das_get_selstr (const DasSelector *pSels, const char *sKey, const char *sOp, const char *sDefault)
 Get the a selection boundary as a raw string. More...
 
int das_get_selint (const DasSelector *pSels, const char *sKey, const char *sOp, int nDefault)
 Get the selection boundary as an integer This function only works for INTEGER parameter types.
 
bool das_get_selbool (const DasSelector *pSels, const char *sKey, bool bDefault)
 Get a selection criteria as a boolean Only works for BOOLEAN format selectors.
 
double das_get_selreal (const DasSelector *pSels, const char *sKey, const char *sOp, double rDefault)
 Search for a selection criteria, return boundary value as a double. More...
 
double das_selreal (const DasSelector *pSel, const char *sOp, double rDefault)
 Get a selection criteria from a particular selector as a double.
 
void das_get_seltime (const DasSelector *pSels, const char *sKey, const char *sOp, int *yr, int *mon, int *dom, int *doy, int *hr, int *min, double *sec)
 Parse the boundary value into a time tuple. More...
 
void das_get_seldastime (const DasSelector *pSels, const char *sKey, const char *sOp, das_time *pDt)
 Equivalent to das_get_seltime but uses the new das_time type from time.h.
 
void das_seldastime (const DasSelector *pSel, const char *sOp, das_time *pDt)
 Equivalent to das_seltime but uses the new das_time type from time.h.
 
const char * das_get_selenum (const DasSelector *pSels, const char *sKey, const char *sDefault)
 A short form of das_getstr for enumeration selectors. More...
 
bool das_get_outenabled (const DasOutput *pOuts, const char *sKey)
 Search for the enabled status for a named output.
 
bool das_outenabled (const DasOutput *pOut)
 Get the enabled status for a given output.
 
double das_get_outinterval (const DasOutput *pOuts, const char *sKey, double rDefault)
 Search for the interval setting for a named output.
 
double das_outinterval (const DasOutput *pOut, double rDefault)
 Get the interval setting for a given output.
 
const char * das_get_outunit (const DasOutput *pOut)
 Get the units for an output.
 
void das_parsecmdline (int nArgs, char **sArgs, DasSelector *pSels, DasOutput *pOuts, const char *sDesc, const char *sFooter)
 Parse a Das 2.3 style commandline, with Das 2.1 support. More...
 
const char * das_progname ()
 Get the program basename Only works after das_parsecmdline() has been called.
 
int das_loglevel ()
 Get the log level. More...
 

Detailed Description

Note: It's time to make a new version of this library that uses functions to setup the selector and output arrays. They are getting complicated enough.

Function Documentation

◆ das_get_selstr()

const char* das_get_selstr ( const DasSelector pSels,
const char *  sKey,
const char *  sOp,
const char *  sDefault 
)

Get the a selection boundary as a raw string.

Since all values are stored internally as strings, this always works.

Parameters
pSelsthe selector array
sKeythe selector key
sOpthe comparison operation string, one of ".ge.", .lt.", etc.
sDefaulta default value to return is this comparison criteria was not provided on the command line.
Returns
The value to compare the parameter with, as a string.

◆ das_get_selreal()

double das_get_selreal ( const DasSelector pSels,
const char *  sKey,
const char *  sOp,
double  rDefault 
)

Search for a selection criteria, return boundary value as a double.

Only works for REAL format selectors

◆ das_get_seltime()

void das_get_seltime ( const DasSelector pSels,
const char *  sKey,
const char *  sOp,
int *  yr,
int *  mon,
int *  dom,
int *  doy,
int *  hr,
int *  min,
double *  sec 
)

Parse the boundary value into a time tuple.

NOTE: Argument doy can be null if you don't care about Day of Year

◆ das_get_selenum()

const char* das_get_selenum ( const DasSelector pSels,
const char *  sKey,
const char *  sDefault 
)

A short form of das_getstr for enumeration selectors.

Enumeration values are always strings, so das_getstr will wolk, this version of that function allows one to leave out the comparitor argument.

◆ das_parsecmdline()

void das_parsecmdline ( int  nArgs,
char **  sArgs,
DasSelector pSels,
DasOutput pOuts,
const char *  sDesc,
const char *  sFooter 
)

Parse a Das 2.3 style commandline, with Das 2.1 support.

Keword=value pair arguments are handled as directed by the selector set. There special argumets are also handled internally.

–das2times=SELECTOR This causes the first two non-special, non keyword.OP.value arguments to be treated as start_time and end_time. It also will search within the third argument to make sure it doesn't contain sub-arugments.

–das2int=OUTPUT This causes the third non-special, non keyword.OP.value arugement to be treated as the sampling resolution. Using this requires the use of –das2times as well.

-h,–help Will print help text

-l LEVEL,–log=LEVEL This will set a global variable indicating which level details the reader should output when writing log messages to standard error. there is no facility for loging in this library this is just a standard way to indicate the caller's preference

Under normal operation the function exits with return value 15 with a message to standard error if there is a runtime problem. If there is a programming issue that should be fixed before release a message is still printed to standard error and 46 is returned.

Parameters
nArgs- The number of argument character strings
sArgs- The arugment string pointer array
pSels- A pointer to the first element of an array of data selectors These define the query parameters for this reader.
sDesc- An optional chunk of text to output as the discription part of the reader help. It may be NULL and is only used if '–help', '-h', or '-?' is detected on the commandline.

◆ das_loglevel()

int das_loglevel ( )

Get the log level.

If -l or –log is not specified on the command line, or this function is called before das_parsecmdline() then the default log level is DAS2_LL_INFO.

Returns
one of: DAS_LL_CRIT, DAS_LL_ERROR, DAS_LL_WARN, DAS_LL_INFO, DAS_LL_DEBUG, DAS_LL_TRACE