main 9.0
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
abrain.c File Reference

abrain.c - 02 May 2023 - aotto1968 More...

#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include "sqlite3.h"
#include "msgque_mq.h"
#include "debug_mq.h"
+ Include dependency graph for abrain.c:

Go to the source code of this file.

Data Structures

struct  BrainCtxS
 the local context of the server tool More...
 

Macros

#define NHI1_FILE_NAME   "abrain.c"
 
#define BrainT   ((typeof(MqContextST)) BrainTT)
 
#define BRAINCTX   ((struct BrainCtxS*const)mqctx)
 
#define MQCTX   ((MQ_CTX*const)brain)
 
#define META_CONTEXT_S   mqctx
 
#define SETUP_brain   struct BrainCtxS*const brain = BRAINCTX
 
#define SETUP_db   sqlite3*const db = brain->db
 
#define SETUP_W(sh)
 
#define SETUP_C(sh)
 
#define DbErrorCheck(f)
 
#define CHECK_ARGS(s)
 
#define check_sqlite(E)    if (unlikely((E) != SQLITE_OK))
 
#define check_NULL(E)    if (unlikely((E) == NULL))
 
#define DB_PREPARE_MAX   100
 
#define READ_C(n)   MK_STRN n; MkErrorCheck(MqReadC(mqctx,&n))
 
#define IdxGet(...)   IdxGet_RT(MK_RT_CALL __VA_ARGS__)
 
#define IdxFinalize(...)   IdxFinalize_RT(MK_RT_CALL __VA_ARGS__)
 
#define HdlGet(...)   HdlGet_RT(MK_RT_CALL __VA_ARGS__)
 
#define ctxCleanup(...)   ctxCleanup_RT(MK_RT_CALL __VA_ARGS__)
 
#define case1(t, f, c)
 
#define GetFromDBnat(...)   GetFromDBnat_RT(MK_RT_CALL __VA_ARGS__)
 
#define GetFromDBary(...)   GetFromDBary_RT(MK_RT_CALL __VA_ARGS__)
 

Functions

static void BrainHelp (const char *base)
 display help using -h or --help command-line option
 
static enum MkErrorE IdxGet_RT (MK_RT const mkrt, MQ_CTX const mqctx, MK_INT *pidx)
 
static enum MkErrorE IdxFinalize_RT (MK_RT const mkrt, MQ_CTX const mqctx, MK_INT idx)
 
static enum MkErrorE HdlGet_RT (MK_RT const mkrt, MQ_CTX const mqctx, sqlite3_stmt **phdl, MK_STRN *pInType, MK_STRN *pInEnd, MK_STRN *pOutType, MK_STRN *pOutEnd)
 
static enum MkErrorE ctxCleanup_RT (MK_RT const mkrt, MQ_CTX const mqctx)
 
static enum MkTypeE GetTypeE (MK_STRB t)
 
static MK_STRB GetTypeS (enum MkTypeE const ntype)
 
static enum MkTypeE GetTypeD (sqlite3_stmt *hdl, MK_INT idx)
 
static enum MkErrorE GetFromDBnat_RT (MK_RT const mkrt, MQ_CTX const mqctx, enum MkTypeE ntype, sqlite3_stmt *hdl, MK_INT idx)
 
static enum MkErrorE GetFromDBary_RT (MK_RT const mkrt, MQ_CTX const mqctx, enum MkTypeE ntype, sqlite3_stmt *hdl, MK_INT idx)
 
static enum MkErrorE STEP (MQ_CALLBACK_SERVICE_CALL_ARGS)
 
static enum MkErrorE EXEC (MQ_CALLBACK_SERVICE_CALL_ARGS)
 
static enum MkErrorE PREP (MQ_CALLBACK_SERVICE_CALL_ARGS)
 
static enum MkErrorE FINA (MQ_CALLBACK_SERVICE_CALL_ARGS)
 
static enum MkErrorE OPEN (MQ_CALLBACK_SERVICE_CALL_ARGS)
 
static enum MkErrorE CLOS (MQ_CALLBACK_SERVICE_CALL_ARGS)
 
static enum MkErrorE BrainCleanup (MQ_CALLBACK_SERVICE_CALL_ARGS)
 
static enum MkErrorE BrainSetup (MQ_CALLBACK_SERVICE_CALL_ARGS)
 
static enum MkErrorE BrainFactory (MQ_CALLBACK_FACTORY_CTOR_ARGS)
 
int main (const int argc, MK_STRN argv[])
 main entry-point for the tool
 

Variables

static MK_TYP BrainTT = NULL
 link to the MqErrorS object
 

Detailed Description

abrain.c - 02 May 2023 - aotto1968

Version
d2cd8f6ec2179f5e5583ae98faed11359996631d
Date
Tue May 2 21:28:46 2023 +0200
Author
aotto1968 aotto.nosp@m.1968.nosp@m.@t-on.nosp@m.line.nosp@m..de

Definition in file abrain.c.

Macro Definition Documentation

◆ BRAINCTX

#define BRAINCTX   ((struct BrainCtxS*const)mqctx)

Definition at line 32 of file abrain.c.

◆ BrainT

#define BrainT   ((typeof(MqContextST)) BrainTT)

Definition at line 31 of file abrain.c.

◆ case1

#define case1 (   t,
  f,
 
)
Value:
case t##T: { \
t dat; \
MkErrorCheck(MkBufferGet ## c(buf,&dat)); \
DbErrorCheck(f(hdl,idx,dat)); \
break; \
}

Definition at line 246 of file abrain.c.

◆ CHECK_ARGS

#define CHECK_ARGS (   s)
Value:
if (MqReadGetNumItems(mqctx)) { \
return MkErrorSetV_4M (mqctx, __func__, SQLITE_ERROR, "usage: %s (%s)\n", __func__, s); \
}
#define MkErrorSetV_4M(m,...)
MQ_EXTERN MK_NUM MqReadGetNumItems(MQ_CTX const ctx) MK_ATTR_HDL

Definition at line 50 of file abrain.c.

◆ check_NULL

#define check_NULL (   E)     if (unlikely((E) == NULL))

Definition at line 56 of file abrain.c.

◆ check_sqlite

#define check_sqlite (   E)     if (unlikely((E) != SQLITE_OK))

Definition at line 54 of file abrain.c.

◆ ctxCleanup

#define ctxCleanup (   ...)    ctxCleanup_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 186 of file abrain.c.

◆ DB_PREPARE_MAX

#define DB_PREPARE_MAX   100

Definition at line 59 of file abrain.c.

◆ DbErrorCheck

#define DbErrorCheck (   f)
Value:
if (unlikely((f) != SQLITE_OK)) { \
MkErrorSetC_4M (mqctx, sqlite3_errmsg(brain->db), __func__, sqlite3_extended_errcode(brain->db)); \
goto error; \
}
#define unlikely(x)

Definition at line 45 of file abrain.c.

◆ GetFromDBary

#define GetFromDBary (   ...)    GetFromDBary_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 303 of file abrain.c.

◆ GetFromDBnat

#define GetFromDBnat (   ...)    GetFromDBnat_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 277 of file abrain.c.

◆ HdlGet

#define HdlGet (   ...)    HdlGet_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 167 of file abrain.c.

◆ IdxFinalize

#define IdxFinalize (   ...)    IdxFinalize_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 140 of file abrain.c.

◆ IdxGet

#define IdxGet (   ...)    IdxGet_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 123 of file abrain.c.

◆ META_CONTEXT_S

#define META_CONTEXT_S   mqctx

Definition at line 34 of file abrain.c.

◆ MQCTX

#define MQCTX   ((MQ_CTX*const)brain)

Definition at line 33 of file abrain.c.

◆ NHI1_FILE_NAME

#define NHI1_FILE_NAME   "abrain.c"

Definition at line 15 of file abrain.c.

◆ READ_C

#define READ_C (   n)    MK_STRN n; MkErrorCheck(MqReadC(mqctx,&n))

Definition at line 104 of file abrain.c.

◆ SETUP_brain

#define SETUP_brain   struct BrainCtxS*const brain = BRAINCTX

Definition at line 35 of file abrain.c.

◆ SETUP_C

#define SETUP_C (   sh)
Value:
MK_STRN key; MK_SIZE klen; \
register sqlite3_stmt *hdl= brain->sh
#define SETUP_brain
Definition abrain.c:35
const MK_STRB * MK_STRN
long MK_SIZE

Definition at line 41 of file abrain.c.

◆ SETUP_db

#define SETUP_db   sqlite3*const db = brain->db

Definition at line 36 of file abrain.c.

◆ SETUP_W

#define SETUP_W (   sh)
Value:
MK_WID key; \
register sqlite3_stmt *hdl= brain->sh
int64_t MK_WID

Definition at line 37 of file abrain.c.

Function Documentation

◆ BrainCleanup()

static enum MkErrorE BrainCleanup ( MQ_CALLBACK_SERVICE_CALL_ARGS  )
static

Definition at line 568 of file abrain.c.

+ Here is the caller graph for this function:

◆ BrainFactory()

static enum MkErrorE BrainFactory ( MQ_CALLBACK_FACTORY_CTOR_ARGS  )
static

Definition at line 599 of file abrain.c.

+ Here is the caller graph for this function:

◆ BrainHelp()

static void BrainHelp ( const char *  base)
static

display help using -h or --help command-line option

Parameters
basethe executable usually: basename(argv[0])

Definition at line 84 of file abrain.c.

+ Here is the caller graph for this function:

◆ BrainSetup()

static enum MkErrorE BrainSetup ( MQ_CALLBACK_SERVICE_CALL_ARGS  )
static

Definition at line 580 of file abrain.c.

+ Here is the caller graph for this function:

◆ CLOS()

static enum MkErrorE CLOS ( MQ_CALLBACK_SERVICE_CALL_ARGS  )
static

Definition at line 520 of file abrain.c.

+ Here is the caller graph for this function:

◆ ctxCleanup_RT()

static enum MkErrorE ctxCleanup_RT ( MK_RT const  mkrt,
MQ_CTX const  mqctx 
)
static

Definition at line 169 of file abrain.c.

◆ EXEC()

static enum MkErrorE EXEC ( MQ_CALLBACK_SERVICE_CALL_ARGS  )
static

Definition at line 418 of file abrain.c.

+ Here is the caller graph for this function:

◆ FINA()

static enum MkErrorE FINA ( MQ_CALLBACK_SERVICE_CALL_ARGS  )
static

Definition at line 510 of file abrain.c.

+ Here is the caller graph for this function:

◆ GetFromDBary_RT()

static enum MkErrorE GetFromDBary_RT ( MK_RT const  mkrt,
MQ_CTX const  mqctx,
enum MkTypeE  ntype,
sqlite3_stmt *  hdl,
MK_INT  idx 
)
inlinestatic

Definition at line 279 of file abrain.c.

◆ GetFromDBnat_RT()

static enum MkErrorE GetFromDBnat_RT ( MK_RT const  mkrt,
MQ_CTX const  mqctx,
enum MkTypeE  ntype,
sqlite3_stmt *  hdl,
MK_INT  idx 
)
inlinestatic

Definition at line 254 of file abrain.c.

◆ GetTypeD()

static enum MkTypeE GetTypeD ( sqlite3_stmt *  hdl,
MK_INT  idx 
)
inlinestatic

Definition at line 226 of file abrain.c.

+ Here is the caller graph for this function:

◆ GetTypeE()

static enum MkTypeE GetTypeE ( MK_STRB  t)
inlinestatic

Definition at line 194 of file abrain.c.

+ Here is the caller graph for this function:

◆ GetTypeS()

static MK_STRB GetTypeS ( enum MkTypeE const  ntype)
inlinestatic

Definition at line 210 of file abrain.c.

+ Here is the caller graph for this function:

◆ HdlGet_RT()

static enum MkErrorE HdlGet_RT ( MK_RT const  mkrt,
MQ_CTX const  mqctx,
sqlite3_stmt **  phdl,
MK_STRN pInType,
MK_STRN pInEnd,
MK_STRN pOutType,
MK_STRN pOutEnd 
)
inlinestatic

Definition at line 142 of file abrain.c.

◆ IdxFinalize_RT()

static enum MkErrorE IdxFinalize_RT ( MK_RT const  mkrt,
MQ_CTX const  mqctx,
MK_INT  idx 
)
inlinestatic

Definition at line 125 of file abrain.c.

◆ IdxGet_RT()

static enum MkErrorE IdxGet_RT ( MK_RT const  mkrt,
MQ_CTX const  mqctx,
MK_INT pidx 
)
static

Definition at line 112 of file abrain.c.

◆ main()

int main ( const int  argc,
MK_STRN  argv[] 
)

main entry-point for the tool

Parameters
argcthe number of command-line arguments
argvthe command-line arguments as an array of strings
Returns
the exit number

Definition at line 616 of file abrain.c.

◆ OPEN()

static enum MkErrorE OPEN ( MQ_CALLBACK_SERVICE_CALL_ARGS  )
static

Definition at line 529 of file abrain.c.

+ Here is the caller graph for this function:

◆ PREP()

static enum MkErrorE PREP ( MQ_CALLBACK_SERVICE_CALL_ARGS  )
static

Definition at line 428 of file abrain.c.

+ Here is the caller graph for this function:

◆ STEP()

static enum MkErrorE STEP ( MQ_CALLBACK_SERVICE_CALL_ARGS  )
static

Definition at line 305 of file abrain.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ BrainTT

MK_TYP BrainTT = NULL
static

link to the MqErrorS object

Definition at line 30 of file abrain.c.