From 9c0078c6b9c1309b48f9ece8b5cad1b9be9a75c5 Mon Sep 17 00:00:00 2001 From: Wiimm Date: Mon, 30 Nov 2020 16:16:56 +0100 Subject: SZS v2.21a --- project/dclib/dclib-file.h | 65 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'project/dclib/dclib-file.h') diff --git a/project/dclib/dclib-file.h b/project/dclib/dclib-file.h index 6f6aee9..bce66b1 100644 --- a/project/dclib/dclib-file.h +++ b/project/dclib/dclib-file.h @@ -183,7 +183,6 @@ static inline int CompareTimeSpecVal static inline int CompareTimeSpecTime ( const struct timespec *a, const time_t tim ) { DASSERT(a); - DASSERT(b); return a->tv_sec < tim ? -1 : a->tv_sec > tim ? 1 : a->tv_nsec > 0; @@ -1328,6 +1327,70 @@ void UpdateOpenFiles ( bool count_current ); uint SetOpenFilesLimit ( uint limit ); ccp PrintOpenFiles ( bool count_current ); // print to circ buffer +// +/////////////////////////////////////////////////////////////////////////////// +/////////////// PrintScript /////////////// +/////////////////////////////////////////////////////////////////////////////// +// [[PrintScriptFF]] // FF = File Format + +typedef enum PrintScriptFF +{ + PSFF_UNKNOWN, // always 0 + PSFF_JSON, + PSFF_BASH, + PSFF_SH, + PSFF_PHP, + PSFF_MAKEDOC, +} +PrintScriptFF; + +ccp GetNamePSFF ( PrintScriptFF fform ); + +//----------------------------------------------------------------------------- +// [[PrintScript_t]] + +typedef struct PrintScript_t +{ + FILE *f; // valid output file + PrintScriptFF fform; // output: file format + ccp varname; // valid ponter to var name + bool create_array; // true: create ar arrays + bool add_index; // true: add index to varname + uint index; // index for array operations + char sep[2]; // separator for JSON + char prefix[100]; // varname prefix +} +PrintScript_t; + +//----------------------------------------------------------------------------- + +static inline void InitializePrintScript ( PrintScript_t *ps ) + { DASSERT(ps); memset(ps,0,sizeof(*ps)); } + +static inline void ResetPrintScript ( PrintScript_t *ps ) + { DASSERT(ps); memset(ps,0,sizeof(*ps)); } + +/////////////////////////////////////////////////////////////////////////////// + +void PrintScriptHeader ( PrintScript_t *ps ); +void PrintScriptFooter ( PrintScript_t *ps ); + +int PutScriptVars +( + PrintScript_t *ps, // valid control struct + uint mode, // bit field: 1=open var, 2:close var + ccp text // text with line of format NAME=VALUE +); + +int PrintScriptVars +( + PrintScript_t *ps, // valid control struct + uint mode, // bit field: 1=open var, 2:close var + ccp format, // format of message + ... // arguments +) +__attribute__ ((__format__(__printf__,3,4))); + // /////////////////////////////////////////////////////////////////////////////// /////////////// E N D /////////////// -- cgit v1.3.1