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

main C file More...

#include <stdint.h>
#include <string.h>
#include "CommandLineInterface/CLIcore.h"
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <dlfcn.h>
#include <unistd.h>
#include <dirent.h>
#include <stddef.h>
#include <sys/resource.h>
#include <termios.h>
#include <sys/time.h>
#include <math.h>
#include <errno.h>
#include <sys/types.h>
#include <getopt.h>
#include <ncurses.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdbool.h>
#include <sys/prctl.h>
#include <sched.h>
#include <signal.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <gsl/gsl_rng.h>
#include <fitsio.h>
#include "ImageStreamIO/ImageStreamIO.h"
#include "00CORE/00CORE.h"
#include "COREMOD_memory/COREMOD_memory.h"
#include "COREMOD_iofits/COREMOD_iofits.h"
#include "COREMOD_arith/COREMOD_arith.h"
#include "CommandLineInterface/calc.h"
#include "CommandLineInterface/calc_bison.h"
Include dependency graph for CLIcore.c:

Macros

#define _GNU_SOURCE
 
#define KNRM   "\x1B[0m"
 
#define KRED   "\x1B[31m"
 
#define KGRN   "\x1B[32m"
 
#define KYEL   "\x1B[33m"
 
#define KBLU   "\x1B[34m"
 
#define KMAG   "\x1B[35m"
 
#define KCYN   "\x1B[36m"
 
#define KWHT   "\x1B[37m"
 
#define KRES   "\033[0m"
 

Functions

void yy_scan_string (const char *)
 
int yylex_destroy (void)
 
static char ** CLI_completion (const char *, int, int)
 
CLIcore functions
int user_function ()
 
void fnExit1 (void)
 
static void runCLI_data_init ()
 
static void runCLI_free ()
 
char * CLI_generator (const char *, int)
 
char * dupstr (char *)
 
void * xmalloc (int)
 
static errno_t memory_re_alloc ()
 
static int command_line_process_options (int argc, char **argv)
 
static int exitCLI ()
 CLI commands. More...
 
static int help ()
 
static errno_t list_commands ()
 
static errno_t list_commands_module (const char *restrict modulename)
 
static errno_t load_sharedobj (const char *restrict libname)
 
static errno_t load_module_shared (const char *restrict modulename)
 
static errno_t load_module_shared_ALL ()
 
static errno_t help_command (const char *restrict cmdkey)
 command help
More...
 
static void set_terminal_echo_on ()
 
errno_t set_signal_catch ()
 signal catching More...
 
static void fprintf_stdout (FILE *f, char const *fmt,...)
 
errno_t write_process_log ()
 Write entry into debug log. More...
 
errno_t write_process_exit_report (const char *restrict errortypestring)
 Write to disk a process report. More...
 
void sig_handler (int signo)
 
static errno_t printInfo ()
 
static errno_t helpreadline ()
 
static errno_t help_cmd ()
 
static errno_t help_module ()
 
static errno_t load_so ()
 
static errno_t load_module ()
 
static errno_t CLIcore__load_module_as__cli ()
 
errno_t set_processinfoON ()
 
errno_t set_processinfoOFF ()
 
errno_t set_default_precision_single ()
 
errno_t set_default_precision_double ()
 
errno_t cfits_usleep_cli ()
 
errno_t functionparameter_CTRLscreen_cli ()
 
errno_t processinfo_CTRLscreen_cli ()
 
errno_t streamCTRL_CTRLscreen_cli ()
 
static errno_t CLI_execute_line ()
 
void rl_cb_linehandler (char *linein)
 Readline callback. More...
 
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)
 
void fnExit_fifoclose ()
 
static errno_t runCLI_initialize ()
 
static errno_t setSHMdir ()
 
static errno_t runCLI_prompt (char *promptstring, char *prompt)
 
errno_t runCLI (int argc, char *argv[], char *promptstring)
 Command Line Interface (CLI) main
. More...
 
static char ** CLI_completion (const char *text, int start, int __attribute__((unused)) end)
 
int CLI_checkarg0 (int argnum, int argtype, int errmsg)
 
int CLI_checkarg (int argnum, int argtype)
 
int CLI_checkarg_noerrmsg (int argnum, int argtype)
 

Variables

int DLib_index
 
void * DLib_handle [1000]
 
pid_t CLIPID
 important directories and info More...
 
uint8_t TYPESIZE [32]
 
int C_ERRNO
 
int Verbose = 0
 
int Listimfile = 0
 
char line [500]
 
int rlquit = false
 
int CLIexecuteCMDready = 0
 
char calctmpimname [200]
 
char CLIstartupfilename [200] = "CLIstartup.txt"
 
static int fifofd
 
static fd_set cli_fdin_set
 
int CLImatchMode = 0
 

Detailed Description

main C file

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

◆ KBLU

#define KBLU   "\x1B[34m"

◆ KCYN

#define KCYN   "\x1B[36m"

◆ KGRN

#define KGRN   "\x1B[32m"

◆ KMAG

#define KMAG   "\x1B[35m"

◆ KNRM

#define KNRM   "\x1B[0m"

◆ KRED

#define KRED   "\x1B[31m"

◆ KRES

#define KRES   "\033[0m"

◆ KWHT

#define KWHT   "\x1B[37m"

◆ KYEL

#define KYEL   "\x1B[33m"

Function Documentation

◆ cfits_usleep_cli()

errno_t cfits_usleep_cli ( )

◆ CLI_checkarg()

int CLI_checkarg ( int  argnum,
int  argtype 
)

◆ CLI_checkarg0()

int CLI_checkarg0 ( int  argnum,
int  argtype,
int  errmsg 
)

◆ CLI_checkarg_noerrmsg()

int CLI_checkarg_noerrmsg ( int  argnum,
int  argtype 
)

◆ CLI_completion() [1/2]

static char** CLI_completion ( const char *  ,
int  ,
int   
)
static

◆ CLI_completion() [2/2]

static char** CLI_completion ( const char *  text,
int  start,
int __attribute__((unused))  end 
)
static

◆ CLI_execute_line()

static errno_t CLI_execute_line ( )
static

◆ CLI_generator()

char * CLI_generator ( const char *  text,
int  state 
)

◆ CLIcore__load_module_as__cli()

static errno_t CLIcore__load_module_as__cli ( )
static

◆ command_line_process_options()

static int command_line_process_options ( int  argc,
char **  argv 
)
static

◆ dupstr()

char * dupstr ( char *  s)

◆ exitCLI()

errno_t exitCLI ( )
static

CLI commands.

CLI functions.

◆ fnExit1()

void fnExit1 ( void  )

◆ fnExit_fifoclose()

void fnExit_fifoclose ( )

◆ fprintf_stdout()

static void fprintf_stdout ( FILE *  f,
char const *  fmt,
  ... 
)
static

◆ functionparameter_CTRLscreen_cli()

errno_t functionparameter_CTRLscreen_cli ( )

◆ help()

static errno_t help ( )
static

◆ help_cmd()

static errno_t help_cmd ( )
static

◆ help_command()

static errno_t help_command ( const char *restrict  cmdkey)
static

command help

Parameters
[in]cmdkeyCommmand name

◆ help_module()

static errno_t help_module ( )
static

◆ helpreadline()

static errno_t helpreadline ( )
static

◆ list_commands()

static errno_t list_commands ( )
static

◆ list_commands_module()

static errno_t list_commands_module ( const char *restrict  modulename)
static

◆ load_module()

static errno_t load_module ( )
static

◆ load_module_shared()

static errno_t load_module_shared ( const char *restrict  modulename)
static

◆ load_module_shared_ALL()

static errno_t load_module_shared_ALL ( )
static

◆ load_sharedobj()

static errno_t load_sharedobj ( const char *restrict  libname)
static

◆ load_so()

static errno_t load_so ( )
static

◆ memory_re_alloc()

static errno_t memory_re_alloc ( )
static

◆ printInfo()

static errno_t printInfo ( )
static

◆ processinfo_CTRLscreen_cli()

errno_t processinfo_CTRLscreen_cli ( )

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

◆ rl_cb_linehandler()

void rl_cb_linehandler ( char *  linein)

Readline callback.

◆ 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

◆ runCLI_data_init()

void runCLI_data_init ( )
static

defaults to floating point type

◆ runCLI_free()

static void runCLI_free ( )
static

◆ runCLI_initialize()

static errno_t runCLI_initialize ( )
static

◆ runCLI_prompt()

static errno_t runCLI_prompt ( char *  promptstring,
char *  prompt 
)
static

◆ set_default_precision_double()

errno_t set_default_precision_double ( )

◆ set_default_precision_single()

errno_t set_default_precision_single ( )

◆ set_processinfoOFF()

errno_t set_processinfoOFF ( )

◆ set_processinfoON()

errno_t set_processinfoON ( )

◆ set_signal_catch()

errno_t set_signal_catch ( )

signal catching

◆ set_terminal_echo_on()

static void set_terminal_echo_on ( )
static

◆ setSHMdir()

static errno_t setSHMdir ( )
static

◆ sig_handler()

void sig_handler ( int  signo)

Signal handler

◆ streamCTRL_CTRLscreen_cli()

errno_t streamCTRL_CTRLscreen_cli ( )

◆ user_function()

int user_function ( )

◆ write_process_exit_report()

errno_t write_process_exit_report ( const char *restrict  errortypestring)

Write to disk a process report.

This function is typically called upon crash to help debugging

errortypestring describes the type of error or reason to issue report

◆ write_process_log()

errno_t write_process_log ( )

Write entry into debug log.

◆ xmalloc()

void * xmalloc ( int  size)

◆ yy_scan_string()

void yy_scan_string ( const char *  )

◆ yylex_destroy()

int yylex_destroy ( void  )

Variable Documentation

◆ C_ERRNO

int C_ERRNO

◆ calctmpimname

char calctmpimname[200]

◆ cli_fdin_set

fd_set cli_fdin_set
static

◆ CLIexecuteCMDready

int CLIexecuteCMDready = 0

◆ CLImatchMode

int CLImatchMode = 0

◆ CLIPID

pid_t CLIPID

important directories and info

◆ CLIstartupfilename

char CLIstartupfilename[200] = "CLIstartup.txt"

◆ DLib_handle

void* DLib_handle[1000]

◆ DLib_index

int DLib_index

◆ fifofd

int fifofd
static

◆ line

char line[500]

◆ Listimfile

int Listimfile = 0

◆ rlquit

int rlquit = false

◆ TYPESIZE

uint8_t TYPESIZE[32]

◆ Verbose

int Verbose = 0