25 #ifndef _POSIX_C_SOURCE 26 #define _POSIX_C_SOURCE 200809L 35 #include <sys/types.h> 37 #include <semaphore.h> 39 #include <gsl/gsl_rng.h> 50 #ifndef __STDC_LIB_EXT1__ 66 #define PI 3.14159265358979323846264338328 69 #define SZ_CLICOREVARRAY 1000 71 #define STRINGMAXLEN_DEFAULT 1000 72 #define STRINGMAXLEN_ERRORMSG 1000 73 #define STRINGMAXLEN_CLICMD 1000 74 #define STRINGMAXLEN_COMMAND 1000 75 #define STRINGMAXLEN_STREAMNAME 100 76 #define STRINGMAXLEN_IMGNAME 100 77 #define STRINGMAXLEN_FILENAME 200 // without directory, includes extension 78 #define STRINGMAXLEN_FULLFILENAME 1000 // includes directory name 79 #define STRINGMAXLEN_FUNCTIONNAME 200 80 #define STRINGMAXLEN_FUNCTIONARGS 1000 81 #define STRINGMAXLEN_SHMDIRNAME 200 96 #define CFITSEXIT printf("Program abnormally terminated, File \"%s\", line %d\n", __FILE__, __LINE__);exit(0) 99 #define nmalloc(f,type,n) f = (type*) malloc(sizeof(type)*n);if(f==NULL){printf("ERROR: pointer \"" #f "\" allocation failed\n");exit(0);}else{printf("\nMALLOC: \""#f "\" allocated\n");} 100 #define nfree(f) free(f);printf("\nMALLOC: \""#f"\" freed\n"); 102 #define nmalloc(f,type,n) f = (type*) malloc(sizeof(type)*n);if(f==NULL){printf("ERROR: pointer \"" #f "\" allocation failed\n");exit(0);} 103 #define nfree(f) free(f); 106 #define TEST_ALLOC(f) if(f==NULL){printf("ERROR: pointer \"" #f "\" allocation failed\n");exit(0);} 109 #define NB_ARG_MAX 20 121 #define INIT_MODULE_LIB(modname) \ 122 static errno_t init_module_CLI(); \ 123 static int INITSTATUS_##modname = 0; \ 124 void __attribute__ ((constructor)) libinit_##modname() \ 126 if ( INITSTATUS_##modname == 0 ) \ 128 strcpy(data.moduleshortname_default, MODULE_SHORTNAME_DEFAULT); \ 129 strcpy(data.modulename, (#modname)); \ 131 RegisterModule(__FILE__, MODULE_APPLICATION, MODULE_DESCRIPTION); \ 132 INITSTATUS_##modname = 1; \ 133 strcpy(data.modulename, ""); \ 134 strcpy(data.moduleshortname_default, ""); \ 135 strcpy(data.moduleshortname, ""); \ 138 void __attribute__ ((destructor)) libclose_##modname() \ 140 if ( INITSTATUS_##modname == 1 ) \ 160 #define PRINT_ERROR(...) do { \ 161 sprintf(data.testpoint_msg, __VA_ARGS__); \ 162 printf("ERROR: %c[%d;%dm %s %c[%d;m\n", (char) 27, 1, 31, data.testpoint_msg, (char) 27, 0); \ 163 sprintf(data.testpoint_file, "%s", __FILE__); \ 164 sprintf(data.testpoint_func, "%s", __func__); \ 165 data.testpoint_line = __LINE__; \ 166 clock_gettime(CLOCK_REALTIME, &data.testpoint_time); \ 169 #define PRINT_ERROR(...) printf("ERROR: %c[%d;%dm %s %c[%d;m\n", (char) 27, 1, 31, __VA_ARGS__, (char) 27, 0) 178 #define PRINT_WARNING(...) do { \ 179 char warnmessage[1000]; \ 180 sprintf(warnmessage, __VA_ARGS__); \ 182 "%c[%d;%dm WARNING [ FILE: %s FUNCTION: %s LINE: %d ] %c[%d;m\n", \ 183 (char) 27, 1, 35, __FILE__, __func__, __LINE__, (char) 27, 0); \ 187 if( strerror_r( errno, buff, 256 ) == 0 ) { \ 188 fprintf(stderr,"C Error: %s\n", buff ); \ 190 fprintf(stderr,"Unknown C Error\n"); \ 193 fprintf(stderr,"No C error (errno = 0)\n"); } \ 194 fprintf(stderr, "%c[%d;%dm ", (char) 27, 1, 35); \ 195 fprintf(stderr, "%s", warnmessage); \ 196 fprintf(stderr, " %c[%d;m\n", (char) 27, 0); \ 207 #if defined NDEBUG || defined STANDALONE 208 #define DEBUG_TRACEPOINT(...) 210 #define DEBUG_TRACEPOINT(...) do { \ 211 sprintf(data.testpoint_file, "%s", __FILE__); \ 212 sprintf(data.testpoint_func, "%s", __func__); \ 213 data.testpoint_line = __LINE__; \ 214 clock_gettime(CLOCK_REALTIME, &data.testpoint_time); \ 215 sprintf(data.testpoint_msg, __VA_ARGS__); \ 224 #if defined NDEBUG || defined STANDALONE 225 #define DEBUG_TRACEPOINTLOG(...) 227 #define DEBUG_TRACEPOINTLOG(...) do { \ 228 sprintf(data.testpoint_file, "%s", __FILE__); \ 229 sprintf(data.testpoint_func, "%s", __func__); \ 230 data.testpoint_line = __LINE__; \ 231 clock_gettime(CLOCK_REALTIME, &data.testpoint_time); \ 232 sprintf(data.testpoint_msg, __VA_ARGS__); \ 233 write_process_log(); \ 251 #define EXECUTE_SYSTEM_COMMAND(...) do { \ 252 char syscommandstring[STRINGMAXLEN_COMMAND]; \ 253 int slen = snprintf(syscommandstring, STRINGMAXLEN_COMMAND, __VA_ARGS__); \ 255 PRINT_ERROR("snprintf wrote <1 char"); \ 258 if(slen >= STRINGMAXLEN_COMMAND) { \ 259 PRINT_ERROR("snprintf string truncation"); \ 262 if(system(syscommandstring) != 0) { \ 263 PRINT_ERROR("system() returns non-zero value\ncommand \"%s\" failed", syscommandstring); \ 274 #define SNPRINTF_CHECK(string, maxlen, ...) do { \ 275 int slen = snprintf(string, maxlen, __VA_ARGS__); \ 277 PRINT_ERROR("snprintf wrote <1 char"); \ 280 if(slen >= maxlen) { \ 281 PRINT_ERROR("snprintf string truncation"); \ 304 #define WRITE_IMAGENAME(imname, ...) do { \ 305 int slen = snprintf(imname, STRINGMAXLEN_IMGNAME, __VA_ARGS__); \ 307 PRINT_ERROR("snprintf wrote <1 char"); \ 310 if(slen >= STRINGMAXLEN_IMGNAME) { \ 311 PRINT_ERROR("snprintf string truncation"); \ 332 #define WRITE_FILENAME(fname, ...) do { \ 333 int slen = snprintf(fname, STRINGMAXLEN_FILENAME, __VA_ARGS__); \ 335 PRINT_ERROR("snprintf wrote <1 char"); \ 338 if(slen >= STRINGMAXLEN_FILENAME) { \ 339 PRINT_ERROR("snprintf string truncation"); \ 362 #define WRITE_FULLFILENAME(ffname, ...) do { \ 363 int slen = snprintf(ffname, STRINGMAXLEN_FULLFILENAME, __VA_ARGS__); \ 365 PRINT_ERROR("snprintf wrote <1 char"); \ 368 if(slen >= STRINGMAXLEN_FULLFILENAME) { \ 369 PRINT_ERROR("snprintf string truncation"); \ 390 #define WRITE_STRING_TO_FILE(fname, ...) do { \ 392 fptmp = fopen(fname, "w"); \ 393 if (fptmp == NULL) { \ 394 int errnum = errno; \ 395 PRINT_ERROR("fopen() returns NULL"); \ 396 fprintf(stderr, "Error opening file %s: %s\n", fname, strerror( errnum )); \ 399 fprintf(fptmp, __VA_ARGS__); \ 416 #define RETURN_SUCCESS 0 417 #define RETURN_FAILURE 1 // generic error code 418 #define RETURN_MISSINGFILE 2 421 #define MAX_NB_FRAMENAME_CHAR 500 422 #define MAX_NB_EXCLUSIONS 40 429 #define CLIARG_FLOAT 1 // floating point number 430 #define CLIARG_LONG 2 // integer (int or long) 431 #define CLIARG_STR_NOT_IMG 3 // string, not existing image 432 #define CLIARG_IMG 4 // existing image 433 #define CLIARG_STR 5 // string 435 #define CLICMD_SUCCESS 0 436 #define CLICMD_INVALID_ARG 1 437 #define CLICMD_ERROR 2 450 #define DATA_NB_MAX_COMMAND 1000 451 #define DATA_NB_MAX_MODULE 100 456 #define STATIC_NB_MAX_IMAGE 520 457 #define STATIC_NB_MAX_VARIABLE 5030 569 char package_name[100];
570 char package_version[100];
575 char shmsemdirname[100];
577 struct sigaction sigact;
597 struct timespec testpoint_time;
624 char CLIlogname[200];
631 char processname[100];
632 char processname0[100];
654 char modulename[100];
655 char moduleshortname[80];
656 char moduleshortname_default[80];
674 #ifdef DATA_STATIC_ALLOC 681 #ifdef DATA_STATIC_ALLOC 690 float FLOATARRAY[1000];
691 double DOUBLEARRAY[1000];
711 const char *restrict FileName,
712 const char *restrict PackageName,
713 const char *restrict InfoString
717 const char *restrict CLIkey,
718 const char *restrict CLImodulesrc,
720 const char *restrict CLIinfo,
721 const char *restrict CLIsyntax,
722 const char *restrict CLIexample,
723 const char *restrict CLICcall
729 #endif // ifndef STANDALONE #define STATIC_NB_MAX_IMAGE
Definition: CLIcore.h:456
int status0
Definition: CLIcore.h:695
#define FPS_NAME_STRMAXLEN
Definition: function_parameters.h:401
int NBKEWORD_DFT
Definition: CLIcore.h:670
Definition: CLIcore.h:567
long l
Definition: CLIcore.h:557
int precision
Definition: CLIcore.h:619
int CLI_checkarg(int argnum, int argtype)
Definition: CLIcore.c:3446
long variableID
Definition: CLIcore.h:55
long numl
Definition: CLIcore.h:529
Tools to help expose and control function parameters.
Function prototypes for ImageStreamIO.
int status1
Definition: CLIcore.h:696
long NB_MAX_VARIABLE
Definition: CLIcore.h:680
gsl_rng * rndgen
Definition: CLIcore.h:618
int signal_USR1
Definition: CLIcore.h:579
int C_ERRNO
Definition: CLIcore.c:165
double INVRANDMAX
Definition: CLIcore.h:617
uid_t suid
Definition: CLIcore.h:606
errno_t runCLI(int argc, char *argv[], char *promptstring)
Command Line Interface (CLI) main .
Definition: CLIcore.c:1661
int errno_t
Definition: CLIcore.h:51
errno_t runCLItest(int argc, char *argv[], char *promptstring)
errno_t set_signal_catch()
signal catching
Definition: CLIcore.c:265
uint_fast8_t BOOL
Definition: CLIcore.h:443
long NB_MAX_MODULE
Definition: CLIcore.h:652
#define STRINGMAXLEN_FUNCTIONNAME
Definition: CLIcore.h:79
Definition: CLIcore.h:480
IMAGE structure The IMAGE structure includes :
Definition: ImageStruct.h:330
errno_t RegisterModule(const char *restrict FileName, const char *restrict PackageName, const char *restrict InfoString)
Definition: CLIcore.c:1229
#define STRINGMAXLEN_FILENAME
Definition: CLIcore.h:77
uid_t euid
Definition: CLIcore.h:605
int processnameflag
Definition: CLIcore.h:633
int Debug
Definition: CLIcore.h:613
double numf
Definition: CLIcore.h:528
int type
Definition: CLIcore.h:553
long cmdindex
Definition: CLIcore.h:644
int signal_PIPE
Definition: CLIcore.h:587
int progStatus
Definition: CLIcore.h:600
#define NB_ARG_MAX
Definition: CLIcore.h:109
int type
Definition: CLIcore.h:525
int parseerror
Definition: CLIcore.h:640
int CLIlogON
Definition: CLIcore.h:623
int signal_BUS
Definition: CLIcore.h:585
long calctmp_imindex
Definition: CLIcore.h:645
long imageID
Definition: CLIcore.h:54
int processinfo
Definition: CLIcore.h:625
VARIABLE * variable
Definition: CLIcore.h:685
errno_t write_process_log()
Write entry into debug log.
Definition: CLIcore.c:331
long NB_MAX_IMAGE
Definition: CLIcore.h:673
PROCESSINFO * pinfo
Definition: CLIcore.h:627
int signal_ABRT
Definition: CLIcore.h:584
long cmdNBarg
Definition: CLIcore.h:641
int CLIloopON
Definition: CLIcore.h:622
int signal_HUP
Definition: CLIcore.h:586
uint8_t TYPESIZE[32]
Definition: CLIcore.c:163
int CLI_checkarg_noerrmsg(int argnum, int argtype)
Definition: CLIcore.c:3455
Definition: CLIcore.h:549
int CMDexecuted
Definition: CLIcore.h:647
int processinfoActive
Definition: CLIcore.h:626
Image structure definition.
Definition: processtools.h:65
uint32_t FPS_CMDCODE
Definition: CLIcore.h:661
uint_fast16_t NBcmd
Definition: CLIcore.h:635
IMAGE * image
Definition: CLIcore.h:677
int signal_TERM
Definition: CLIcore.h:581
int signal_SEGV
Definition: CLIcore.h:583
long NB_MAX_COMMAND
Definition: CLIcore.h:637
Definition: CLIcore.h:494
int SHARED_DFT
Definition: CLIcore.h:667
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)
Definition: CLIcore.c:1288
int signal_USR2
Definition: CLIcore.h:580
int rmSHMfile
Definition: CLIcore.h:616
double f
Definition: CLIcore.h:556
int signal_INT
Definition: CLIcore.h:582
void sig_handler(int signo)
Definition: CLIcore.c:468
long NBmodule
Definition: CLIcore.h:651
int quiet
Definition: CLIcore.h:614
#define STATIC_NB_MAX_VARIABLE
Definition: CLIcore.h:457
Data streams control panel.
pid_t CLIPID
important directories and info
Definition: CLIcore.c:160
#define STRINGMAXLEN_FUNCTIONARGS
Definition: CLIcore.h:80
int used
Definition: CLIcore.h:551
int overwrite
Definition: CLIcore.h:615
uid_t ruid
Definition: CLIcore.h:604
int testpoint_line
Definition: CLIcore.h:593
Definition: CLIcore.h:523
int fifoON
Definition: CLIcore.h:630