cacao  Release 0.1.03-dev
Compute And Control For Adaptive Optics
CLIcore.h File Reference

Command line interface. More...

#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <semaphore.h>
#include <fftw3.h>
#include <gsl/gsl_rng.h>
#include <signal.h>
#include <string.h>
#include "ImageStreamIO/ImageStreamIO.h"
#include "ImageStreamIO/ImageStruct.h"
#include "processtools.h"
#include "streamCTRL.h"
#include "function_parameters.h"
Include dependency graph for CLIcore.h:

Go to the source code of this file.

Data Structures

struct  CMD
 
struct  MODULE
 
struct  CMDARGTOKEN
 
struct  VARIABLE
 
struct  DATA
 

Macros

#define _CLICORE_H
 
#define _POSIX_C_SOURCE   200809L
 
#define PI   3.14159265358979323846264338328
 
#define SZ_CLICOREVARRAY   1000
 Size of array CLICOREVARRAY. More...
 
#define STRINGMAXLEN_DEFAULT   1000
 
#define STRINGMAXLEN_ERRORMSG   1000
 
#define STRINGMAXLEN_CLICMD   1000
 
#define STRINGMAXLEN_COMMAND   1000
 
#define STRINGMAXLEN_STREAMNAME   100
 
#define STRINGMAXLEN_IMGNAME   100
 
#define STRINGMAXLEN_FILENAME   200
 
#define STRINGMAXLEN_FULLFILENAME   1000
 
#define STRINGMAXLEN_FUNCTIONNAME   200
 
#define STRINGMAXLEN_FUNCTIONARGS   1000
 
#define STRINGMAXLEN_SHMDIRNAME   200
 
#define CFITSEXIT   printf("Program abnormally terminated, File \"%s\", line %d\n", __FILE__, __LINE__);exit(0)
 
#define nmalloc(f, type, n)   f = (type*) malloc(sizeof(type)*n);if(f==NULL){printf("ERROR: pointer \"" #f "\" allocation failed\n");exit(0);}
 
#define nfree(f)   free(f);
 
#define TEST_ALLOC(f)   if(f==NULL){printf("ERROR: pointer \"" #f "\" allocation failed\n");exit(0);}
 
#define NB_ARG_MAX   20
 
#define INIT_MODULE_LIB(modname)
 Initialize module. More...
 
#define PRINT_ERROR(...)
 Print error (in red) and continue. More...
 
#define PRINT_WARNING(...)
 Print warning and continue. More...
 
#define DEBUG_TRACEPOINT(...)
 register trace point More...
 
#define DEBUG_TRACEPOINTLOG(...)
 register and log trace point More...
 
#define EXECUTE_SYSTEM_COMMAND(...)
 system call with error checking and handling More...
 
#define SNPRINTF_CHECK(string, maxlen, ...)
 snprintf with error checking and handling More...
 
#define WRITE_IMAGENAME(imname, ...)
 Write image name to string. More...
 
#define WRITE_FILENAME(fname, ...)
 Write filename to string. More...
 
#define WRITE_FULLFILENAME(ffname, ...)
 Write full path filename to string. More...
 
#define WRITE_STRING_TO_FILE(fname, ...)
 Write a string to file. More...
 
#define RETURN_SUCCESS   0
 
#define RETURN_FAILURE   1
 
#define RETURN_MISSINGFILE   2
 
#define MAX_NB_FRAMENAME_CHAR   500
 
#define MAX_NB_EXCLUSIONS   40
 
#define CLIARG_FLOAT   1
 
#define CLIARG_LONG   2
 
#define CLIARG_STR_NOT_IMG   3
 
#define CLIARG_IMG   4
 
#define CLIARG_STR   5
 
#define CLICMD_SUCCESS   0
 
#define CLICMD_INVALID_ARG   1
 
#define CLICMD_ERROR   2
 
#define FALSE   0
 
#define TRUE   1
 
#define DATA_NB_MAX_COMMAND   1000
 
#define DATA_NB_MAX_MODULE   100
 
#define STATIC_NB_MAX_IMAGE   520
 
#define STATIC_NB_MAX_VARIABLE   5030
 

Typedefs

typedef int errno_t
 
typedef long imageID
 
typedef long variableID
 
typedef uint_fast8_t BOOL
 

Functions

int CLI_checkarg (int argnum, int argtype)
 
int CLI_checkarg_noerrmsg (int argnum, int argtype)
 
errno_t set_signal_catch ()
 signal catching More...
 
void sig_handler (int signo)
 
errno_t RegisterModule (const char *restrict FileName, const char *restrict PackageName, const char *restrict InfoString)
 
uint_fast16_t RegisterCLIcommand (const char *restrict CLIkey, const char *restrict CLImodulesrc, errno_t(*CLIfptr)(), const char *restrict CLIinfo, const char *restrict CLIsyntax, const char *restrict CLIexample, const char *restrict CLICcall)
 
errno_t runCLItest (int argc, char *argv[], char *promptstring)
 
errno_t runCLI (int argc, char *argv[], char *promptstring)
 Command Line Interface (CLI) main
. More...
 
errno_t write_process_log ()
 Write entry into debug log. More...
 

Variables

pid_t CLIPID
 important directories and info More...
 
char DocDir [200]
 
char SrcDir [200]
 
char BuildFile [200]
 
char BuildDate [200]
 
char BuildTime [200]
 
int C_ERRNO
 
uid_t euid_real
 
uid_t euid_called
 
uid_t suid
 
uint8_t TYPESIZE [32]
 
DATA data
 

Detailed Description

Command line interface.

Command line interface (CLI) definitions and function prototypes

Macro Definition Documentation

◆ _CLICORE_H

#define _CLICORE_H

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   200809L

◆ CFITSEXIT

#define CFITSEXIT   printf("Program abnormally terminated, File \"%s\", line %d\n", __FILE__, __LINE__);exit(0)

◆ CLIARG_FLOAT

#define CLIARG_FLOAT   1

◆ CLIARG_IMG

#define CLIARG_IMG   4

◆ CLIARG_LONG

#define CLIARG_LONG   2

◆ CLIARG_STR

#define CLIARG_STR   5

◆ CLIARG_STR_NOT_IMG

#define CLIARG_STR_NOT_IMG   3

◆ CLICMD_ERROR

#define CLICMD_ERROR   2

◆ CLICMD_INVALID_ARG

#define CLICMD_INVALID_ARG   1

◆ CLICMD_SUCCESS

#define CLICMD_SUCCESS   0

◆ DATA_NB_MAX_COMMAND

#define DATA_NB_MAX_COMMAND   1000

◆ DATA_NB_MAX_MODULE

#define DATA_NB_MAX_MODULE   100

◆ FALSE

#define FALSE   0

◆ INIT_MODULE_LIB

#define INIT_MODULE_LIB (   modname)
Value:
static errno_t init_module_CLI(); /* forward declaration */ \
static int INITSTATUS_##modname = 0; \
void __attribute__ ((constructor)) libinit_##modname() \
{ \
if ( INITSTATUS_##modname == 0 ) /* only run once */ \
{ \
strcpy(data.modulename, (#modname)); \
init_module_CLI(); \
RegisterModule(__FILE__, MODULE_APPLICATION, MODULE_DESCRIPTION); \
INITSTATUS_##modname = 1; \
strcpy(data.modulename, ""); /* reset after use */ \
strcpy(data.moduleshortname_default, ""); /* reset after use */ \
strcpy(data.moduleshortname, ""); /* reset after use */ \
} \
} \
void __attribute__ ((destructor)) libclose_##modname() \
{ \
if ( INITSTATUS_##modname == 1 ) \
{ \
} \
}
#define MODULE_APPLICATION
Definition: 00CORE.c:27
char moduleshortname_default[80]
Definition: CLIcore.h:656
char modulename[100]
Definition: CLIcore.h:654
#define MODULE_SHORTNAME_DEFAULT
Definition: 00CORE.c:21
int errno_t
Definition: AOloopControl_IOtools.h:20
static errno_t init_module_CLI()
Definition: 00CORE.c:112
void __attribute__((constructor)) libinit_00CORE()
Definition: ImageStreamIO.c:77
DATA data
char moduleshortname[80]
Definition: CLIcore.h:655
#define MODULE_DESCRIPTION
Definition: 00CORE.c:24

Initialize module.

◆ MAX_NB_EXCLUSIONS

#define MAX_NB_EXCLUSIONS   40

◆ MAX_NB_FRAMENAME_CHAR

#define MAX_NB_FRAMENAME_CHAR   500

◆ NB_ARG_MAX

#define NB_ARG_MAX   20

◆ nfree

#define nfree (   f)    free(f);

◆ nmalloc

#define nmalloc (   f,
  type,
 
)    f = (type*) malloc(sizeof(type)*n);if(f==NULL){printf("ERROR: pointer \"" #f "\" allocation failed\n");exit(0);}

◆ PI

#define PI   3.14159265358979323846264338328

◆ RETURN_FAILURE

#define RETURN_FAILURE   1

◆ RETURN_MISSINGFILE

#define RETURN_MISSINGFILE   2

◆ RETURN_SUCCESS

#define RETURN_SUCCESS   0

◆ STATIC_NB_MAX_IMAGE

#define STATIC_NB_MAX_IMAGE   520

◆ STATIC_NB_MAX_VARIABLE

#define STATIC_NB_MAX_VARIABLE   5030

◆ STRINGMAXLEN_CLICMD

#define STRINGMAXLEN_CLICMD   1000

◆ STRINGMAXLEN_COMMAND

#define STRINGMAXLEN_COMMAND   1000

◆ STRINGMAXLEN_DEFAULT

#define STRINGMAXLEN_DEFAULT   1000

◆ STRINGMAXLEN_ERRORMSG

#define STRINGMAXLEN_ERRORMSG   1000

◆ STRINGMAXLEN_FILENAME

#define STRINGMAXLEN_FILENAME   200

◆ STRINGMAXLEN_FULLFILENAME

#define STRINGMAXLEN_FULLFILENAME   1000

◆ STRINGMAXLEN_FUNCTIONARGS

#define STRINGMAXLEN_FUNCTIONARGS   1000

◆ STRINGMAXLEN_FUNCTIONNAME

#define STRINGMAXLEN_FUNCTIONNAME   200

◆ STRINGMAXLEN_IMGNAME

#define STRINGMAXLEN_IMGNAME   100

◆ STRINGMAXLEN_SHMDIRNAME

#define STRINGMAXLEN_SHMDIRNAME   200

◆ STRINGMAXLEN_STREAMNAME

#define STRINGMAXLEN_STREAMNAME   100

◆ SZ_CLICOREVARRAY

#define SZ_CLICOREVARRAY   1000

Size of array CLICOREVARRAY.

◆ TEST_ALLOC

#define TEST_ALLOC (   f)    if(f==NULL){printf("ERROR: pointer \"" #f "\" allocation failed\n");exit(0);}

◆ TRUE

#define TRUE   1

Typedef Documentation

◆ BOOL

typedef uint_fast8_t BOOL

◆ errno_t

typedef int errno_t

◆ imageID

typedef long imageID

◆ variableID

typedef long variableID

Function Documentation

◆ CLI_checkarg()

int CLI_checkarg ( int  argnum,
int  argtype 
)

◆ CLI_checkarg_noerrmsg()

int CLI_checkarg_noerrmsg ( int  argnum,
int  argtype 
)

◆ RegisterCLIcommand()

uint_fast16_t RegisterCLIcommand ( const char *restrict  CLIkey,
const char *restrict  CLImodulesrc,
errno_t(*)()  CLIfptr,
const char *restrict  CLIinfo,
const char *restrict  CLIsyntax,
const char *restrict  CLIexample,
const char *restrict  CLICcall 
)

◆ RegisterModule()

errno_t RegisterModule ( const char *restrict  FileName,
const char *restrict  PackageName,
const char *restrict  InfoString 
)

◆ runCLI()

errno_t runCLI ( int  argc,
char *  argv[],
char *  promptstring 
)

Command Line Interface (CLI) main
.

uses readline to read user input
parsing done with bison and flex

becomes 1 after startup

◆ runCLItest()

errno_t runCLItest ( int  argc,
char *  argv[],
char *  promptstring 
)

◆ set_signal_catch()

errno_t set_signal_catch ( )

signal catching

◆ sig_handler()

void sig_handler ( int  signo)

Signal handler

◆ write_process_log()

errno_t write_process_log ( )

Write entry into debug log.

Variable Documentation

◆ BuildDate

char BuildDate[200]

◆ BuildFile

char BuildFile[200]

◆ BuildTime

char BuildTime[200]

◆ C_ERRNO

int C_ERRNO

◆ CLIPID

pid_t CLIPID

important directories and info

◆ data

DATA data

◆ DocDir

char DocDir[200]

◆ euid_called

uid_t euid_called

◆ euid_real

uid_t euid_real

◆ SrcDir

char SrcDir[200]

◆ suid

uid_t suid

◆ TYPESIZE

uint8_t TYPESIZE[32]