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

core functions More...

#include <fitsio.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <time.h>
#include "CommandLineInterface/CLIcore.h"
#include "COREMOD_memory/COREMOD_memory.h"
#include "00CORE/00CORE.h"
Include dependency graph for 00CORE.c:

Macros

#define MODULE_SHORTNAME_DEFAULT   ""
 
#define MODULE_DESCRIPTION   "Core functions"
 
#define MODULE_APPLICATION   "milk"
 

Functions

Module initialization
static errno_t init_module_CLI ()
 
int printRED (char *string)
 Print string in red. More...
 
errno_t printWARNING (const char *restrict file, const char *restrict func, int line, const char *restrict warnmessage)
 Print warning and continue. More...
 
errno_t printERROR (const char *restrict file, const char *restrict func, int line, const char *restrict errmessage)
 Print error (in red) and continue. More...
 
void CORE_logFunctionCall (const int funclevel, const int loglevel, const int logfuncMODE, __attribute__((unused)) const char *FileName, const char *FunctionName, const long line, char *comments)
 
int set_precision (int vp)
 
int CLIinfoPrint ()
 
int CLIWritePid ()
 
struct timespec timespec_diff (struct timespec start, struct timespec end)
 
double timespec_diff_double (struct timespec start, struct timespec end)
 
int file_exist (char *filename)
 

Detailed Description

core functions

Useful functions frequently used by modules

Macro Definition Documentation

◆ MODULE_APPLICATION

#define MODULE_APPLICATION   "milk"

◆ MODULE_DESCRIPTION

#define MODULE_DESCRIPTION   "Core functions"

◆ MODULE_SHORTNAME_DEFAULT

#define MODULE_SHORTNAME_DEFAULT   ""

Function Documentation

◆ CLIinfoPrint()

int CLIinfoPrint ( )

◆ CLIWritePid()

int CLIWritePid ( )

◆ CORE_logFunctionCall()

void CORE_logFunctionCall ( const int  funclevel,
const int  loglevel,
const int  logfuncMODE,
__attribute__((unused)) const char *  FileName,
const char *  FunctionName,
const long  line,
char *  comments 
)

Purpose

Log function call (for testing / debugging only).

Function calls are logged if to file .FileName.funccalls.log

Variable AOLOOPCONTROL_logfunc_level keeps track of function depth:
it is incremented when entering a function
decremented when exiting a function

Variable AOLOOPCONTROL_logfunc_level_max sets the max depth of logging

At the beginning of each function, insert this code:

#ifdef TEST
CORE_logFunctionCall( logfunc_level, logfunc_level_max, 1, __FILE__, __func__, __LINE__, "");
#endif

and at the end of each function:

#ifdef TEST
CORE_logFunctionCall( logfunc_level, logfunc_level_max, 1, __FILE__, __func__, __LINE__, "");
#endif

Arguments

Parameters
[in]funclevelINT Function level (0: top level, always log)
[in]loglevelINT Log level: log all function with level =< loglevel

logfuncMODE INT Log mode, 0:entering function, 1:exiting function

Parameters
[in]FileNamechar* Name of source file, usually FILE so that preprocessor fills this parameter.
[in]FunctionNamechar* Name of function, usually FUNCTION so that preprocessor fills this parameter.
[in]linechar* Line in cource code, usually LINE so that preprocessor fills this parameter.
[in]commentschar* comment string
Returns
void
Note
Carefully set depth value to avoid large output file.
Warning
May slow down code. Only use for debugging. Output file may grow very quickly.

◆ file_exist()

int file_exist ( char *  filename)

◆ init_module_CLI()

static errno_t init_module_CLI ( )
static

◆ printERROR()

errno_t printERROR ( const char *restrict  file,
const char *restrict  func,
int  line,
const char *restrict  errmessage 
)

Print error (in red) and continue.

Purpose

Print error string

Arguments

Parameters
[in]fileCHAR* file name from which error is issued
[in]funcCHAR* function name from which error is issued
[in]lineint line number from which error is issued
[in]warnmessageCHAR* error message to be printed

◆ printRED()

int printRED ( char *  string)

Print string in red.

Purpose

Print red string to stdout

Arguments

Parameters
[in]stringCHAR*

◆ printWARNING()

errno_t printWARNING ( const char *restrict  file,
const char *restrict  func,
int  line,
const char *restrict  warnmessage 
)

Print warning and continue.

Purpose

Print warning string

Arguments

Parameters
[in]fileCHAR* file name from which warning is issued
[in]funcCHAR* function name from which warning is issued
[in]lineint line number from which warning is issued
[in]warnmessageCHAR* warning message to be printed

Color codes for printf 30 Black 31 Red 32 Green 33 Yellow 34 Blue 35 Magenta 36 Cyan 37 White

◆ set_precision()

int set_precision ( int  vp)

Purpose

Set default precision (single or double)

Arguments

Parameters
[in]vpint precision mode
[in]warnmessageCHAR* error message to be printed
  • 0: single precision
  • 1: double precision

◆ timespec_diff()

struct timespec timespec_diff ( struct timespec  start,
struct timespec  end 
)

◆ timespec_diff_double()

double timespec_diff_double ( struct timespec  start,
struct timespec  end 
)