milk  1.01
Modular Image processing Library toolKit
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 "config.h"
#include "ImageStreamIO/ImageStreamIO.h"
#include "ImageStreamIO/ImageStruct.h"
#include "CommandLineInterface/processtools.h"
#include "CommandLineInterface/streamCTRL.h"
#include "CommandLineInterface/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.
 
#define STRINGMAXLEN_DEFAULT   1000
 
#define STRINGMAXLEN_ERRORMSG   1000
 
#define STRINGMAXLEN_CLICMDLINE   1000
 
#define STRINGMAXLEN_COMMAND   1000
 
#define STRINGMAXLEN_STREAMNAME   100
 
#define STRINGMAXLEN_IMGNAME   100
 
#define STRINGMAXLEN_FILENAME   200
 
#define STRINGMAXLEN_DIRNAME   800
 
#define STRINGMAXLEN_FULLFILENAME   1000
 
#define STRINGMAXLEN_FUNCTIONNAME   200
 
#define STRINGMAXLEN_FUNCTIONARGS   1000
 
#define STRINGMAXLEN_SHMDIRNAME   200
 
#define STRINGMAXLEN_FPSPROCESSTYPE   64
 
#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 CREATE_IMAGENAME(imname, ...)
 
#define WRITE_DIRNAME(dirname, ...)
 Write directory 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
 
#define CMDARG_TYPE_UNSOLVED   0
 
#define CMDARG_TYPE_FLOAT   1
 
#define CMDARG_TYPE_LONG   2
 
#define CMDARG_TYPE_STRING   3
 
#define CMDARG_TYPE_EXISTINGIMAGE   4
 
#define CMDARG_TYPE_COMMAND   5
 
#define CMDARG_TYPE_RAWSTRING   6
 

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)
 Signal handler. More...
 
errno_t RegisterModule (const char *restrict FileName, const char *restrict PackageName, const char *restrict InfoString, int versionmajor, int versionminor, int versionpatch)
 
uint32_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 CLI_execute_line ()
 
errno_t write_process_log ()
 Write entry into debug log. More...
 

Variables

pid_t CLIPID
 important directories and info
 
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

◆ CREATE_IMAGENAME

#define CREATE_IMAGENAME (   imname,
  ... 
)
Value:
char imname[STRINGMAXLEN_IMGNAME]; \
do { \
int slen = snprintf(imname, STRINGMAXLEN_IMGNAME, __VA_ARGS__); \
if(slen<1) { \
PRINT_ERROR("snprintf wrote <1 char"); \
abort(); \
} \
if(slen >= STRINGMAXLEN_IMGNAME) { \
PRINT_ERROR("snprintf string truncation"); \
abort(); \
} \
} while(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.moduleshortname_default, MODULE_SHORTNAME_DEFAULT); \
strcpy(data.moduledatestring, __DATE__); \
strcpy(data.moduletimestring, __TIME__); \
strcpy(data.modulename, (#modname)); \
RegisterModule(__FILE__, PROJECT_NAME, MODULE_DESCRIPTION, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); \
init_module_CLI(); \
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 ) \
{ \
} \
}

Initialize module.

Function Documentation

◆ 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

◆ 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.

__attribute__
errno_t __attribute__((hot))
Logs a shared memory stream onto disk.
Definition: logshmim.c:685
init_module_CLI
static errno_t init_module_CLI()
Initialize module CLI.
Definition: milk_module_example.c:188