ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcb.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <signal.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include <byteswap.h>

Go to the source code of this file.

Classes

union  ngcbSEMIPC_CTL
 
struct  ngcb_time_v
 
struct  ngcb_time_hr
 
struct  ngcb_ma_t
 
struct  ngcb_rm_t
 
struct  ngcb_cube_t
 

Macros

#define USE(x)
 
#define ngcb_open(p, m)
 
#define ngcb_lseek(f, o, w)
 
#define ngcb_fopen(p, m)
 
#define ngcb_ftello(s)
 
#define ngcb_fseeko(s, o, w)
 
#define ngcb_ftruncate(s, o)
 
#define ngcb_stat(p, s)
 
#define ngcb_statvfs(p, s)
 
#define ngcb_mmap(s, l, p, fl, fd, o)
 
#define str2str(s1, s2, n)
 
#define _vecsize(x)
 
#define _ngcb_cv(a)
 
#define _ngcb_tostr(a)
 
#define NGCB_CODE_POS   __FILE__ ":" _ngcb_tostr(__LINE__)
 
#define ngcbLog(...)
 
#define ngcbFmt(...)
 
#define ngcbSUCCESS   0
 
#define ngcbABORTED   1
 
#define ngcbFAILURE   -1
 
#define ngcbWARNING   -2
 
#define ngcbSKIP   -3
 
#define ngcbERR_SEVERE   -4
 
#define ngcbERR_ACCESS   -5
 
#define ngcbDISCONNECT   -6
 
#define ngcbMAX_KEY_LEN   256
 
#define ngcbMAX_KEYELE_LEN   512
 
#define ngcbFITS_TYPE_INT   1
 
#define ngcbFITS_TYPE_FLOAT   2
 
#define ngcbFITS_TYPE_DOUBLE   3
 
#define ngcbFITS_TYPE_STRING   4
 
#define ngcbFITS_TYPE_LOGICAL   5
 
#define ngcbFITS_TYPE_FREE   6
 
#define ngcbFITS_TYPE_COMMENT   7
 
#define ngcbFITS_LINE_LEN   80
 
#define ngcbFITS_KEY_SIZE   48
 
#define ngcbFITS_BLOCK_LINES   36
 
#define ngcbFITS_BLOCK_LEN   (ngcbFITS_LINE_LEN * ngcbFITS_BLOCK_LINES)
 
#define ngcbDiffTime(t1, t2)
 
#define ngcbDiffTimeHR(t1, t2)
 
#define ngcbLITTLE_ENDIAN   0
 
#define ngcbBIG_ENDIAN   1
 
#define ngcbMEMCPY   0
 
#define ngcbNETCPY   1
 
#define ngcbSCPY   2
 

Typedefs

typedef off_t ngcb_off_t
 
typedef struct stat ngcb_stat_t
 
typedef struct statvfs ngcb_statvfs_t
 
typedef int(* ngcb_sig_t) (int how, const sigset_t *set, sigset_t *oset)
 
typedef int(* ngcb_fct) (void)
 
typedef void(* ngcb_void_fct) (void)
 
typedef char ngcb_str32_t[32]
 
typedef char ngcb_str64_t[64]
 
typedef char ngcb_str128_t[128]
 
typedef char ngcb_str256_t[256]
 
typedef char ngcb_str512_t[512]
 

Functions

int ngcbTaiOffset ()
 
int ngcbGetTime (struct timeval *t)
 
void ngcbSubTime (struct timeval t1, struct timeval t2, struct timeval *t3)
 
void ngcbAddTime (struct timeval t1, struct timeval t2, struct timeval *t3)
 
void ngcbAddTimeFrac (uint64_t *sec, uint64_t *nsec, double t)
 
void ngcbTimeFrac2Str (char *value, uint64_t sec, uint64_t nsec)
 
void ngcbAddSec (struct timeval *t, double seconds)
 
int ngcbGetUTC (char *utc, int precision)
 
double ngcbGetMJD (void)
 
void ngcbTime2UTC (struct timeval t, char *utc, int precision)
 
double ngcbTime2MJD (struct timeval t)
 
void ngcbMJD2UTC (double mjd, char *utc, int precision)
 
double ngcbUTC2MJD (const char *utc)
 
int ngcbMicroSleep (int fd, int waitTime)
 
int ngcbSleep (int fd, int waitTime)
 
FILE * ngcbDebugOpen (char *erms)
 
void ngcbDebugClose (FILE *debugStream)
 
void ngcbPrint (FILE *fd, void *buffer, size_t size, int bitPix, size_t max)
 
FILE * ngcbWatchdogOpen (int verbose, char *erms)
 
void ngcbWatchdogClose (FILE *wd)
 
void ngcbWatchdogAddProc (FILE *wd, const char *host, int pid)
 
void ngcbWatchdogRemoveProc (FILE *wd, const char *host, int pid)
 
void ngcbWatchdogClearProc (FILE *wd, const char *host)
 
void ngcbWatchdogAddCmd (FILE *wd, const char *host, const char *cmd)
 
void ngcbWatchdogRemoveCmd (FILE *wd, const char *host, const char *cmd)
 
void ngcbWatchdogClearCmd (FILE *wd, const char *host)
 
void ngcbWatchdogDbWrite (FILE *wd, const char *host, const char *attr, const char *value)
 
int ngcbEndian (void)
 
void ngcbSwap2 (void *buffer, size_t length)
 
void ngcbSwap4 (void *buffer, size_t length)
 
void ngcbSwap8 (void *buffer, size_t length)
 
void ngcbInt2Bin (char *str, int in)
 
void ngcbUInt2Bin (char *str, unsigned int in)
 
int ngcbBin2Int (const char *str)
 
unsigned int ngcbBin2UInt (const char *str)
 
void ngcbFilterInit (ngcb_ma_t *f, int size)
 
void ngcbFilterDelete (ngcb_ma_t *f)
 
void ngcbFilterReset (ngcb_ma_t *f)
 
double ngcbFilter (ngcb_ma_t *f, double value)
 
void ngcbMedianInit (ngcb_rm_t *f, int size)
 
void ngcbMedianDelete (ngcb_rm_t *f)
 
void ngcbMedianReset (ngcb_rm_t *f)
 
int ngcbRunningMedian (ngcb_rm_t *f, int value)
 
int ngcbRound (double x)
 
int ngcbRoundL (long double x)
 
int64_t ngcbRound64 (double x)
 
int64_t ngcbRound64L (long double x)
 
double ngcbMean16 (unsigned short *a, int n)
 
double ngcbMean32 (int *a, int n)
 
double ngcbMeanR32 (float *a, int n)
 
double ngcbMeanR64 (double *a, int n)
 
unsigned short ngcbMedian16 (unsigned short *a, int n)
 
int ngcbMedian32 (int *a, int n)
 
float ngcbMedianR32 (float *a, int n)
 
int ngcbExecDaemon (int bg)
 
void ngcbExecShell (const char *shell)
 
int ngcbExecInit (const char *host, int *version, char *erms)
 
int ngcbExecVersion (const char *host, char *erms)
 
int ngcbExecutor (int argc, char **argv)
 
int ngcbExec (const char *host, int *pid, const char *cmd, char *reply, char *erms)
 
int ngcbExecDbg (const char *host, int *pid, const char *cmd, char *reply, int port, char *erms)
 
int ngcbExecXt (const char *host, int *pid, const char *cmd, char *reply, const char *geom, char *erms)
 
int ngcbKill (const char *host, int pid, char *erms)
 
void ngcbExecReply (int fd, int success, const char *reply)
 
int ngcbRemoteFileOpen (const char *host, const char *fileName, size_t *size, char *erms)
 
void ngcbRemoteFileClose (int fd)
 
int ngcbRemoteFileDelete (const char *host, const char *fileName, char *erms)
 
int ngcbLoadFile (const char *fileName, char *buffer, size_t *size, char *erms)
 
int ngcbWriteFile (const char *fileName, const char *buffer, size_t size, char *erms)
 
int ngcbMapFile (const char *fileName, char **buffer, size_t *size, char *erms)
 
void ngcbUnmapFile (int fd, char *buffer, size_t size)
 
long int ngcbFileSize (const char *fileName, char *erms)
 
ssize_t ngcbRead (int fd, void *buffer, size_t size, char *erms)
 
ssize_t ngcbWrite (int fd, const void *buffer, size_t size, char *erms)
 
const char * ngcbGetFileExt (const char *fileName)
 
const char * ngcbProcName (const char *path)
 
void ngcbParentDir (char *path, const char *fileName)
 
int ngcbMkDir (const char *path, mode_t mode, char *erms)
 
int ngcbFileExists (const char *path)
 
int ngcbIsDir (const char *path)
 
int ngcbReadPerm (const char *path)
 
int ngcbWritePerm (const char *path)
 
void ngcbExpand (char *path)
 
int ngcbPathCmp (const char *path1, const char *path2)
 
double ngcbDiskSpace (const char *path, char *erms)
 
void ngcbCleanPath (char *name)
 
int ngcbSkipFd (FILE *stream)
 
int ngcbWin2File (FILE *fd, const char *buffer, size_t fx, size_t fy, int bitPix, size_t sx, size_t sy, size_t nx, size_t ny, int rot, char *erms)
 
void * ngcbFileBufAlloc (size_t size, char *erms)
 
void ngcbFileBufFree (void *buffer)
 
int ngcbFdCnt (void)
 
int ngcbFindIndex (const char *path, int minIndex, char *erms)
 
void ngcbToLower (char *s)
 
void ngcbToUpper (char *s)
 
void ngcbCleanSpace (char *s)
 
void ngcbTrimSpace (char *s)
 
void ngcbStr2Arg (char *s, int *argc, char **argv)
 
void ngcbStrPut (char *s1, const char *s2)
 
int ngcbReplaceEnv (char *string, char *erms)
 
int ngcbIsFloat (const char *s)
 
int ngcbStr2Int (const char *s, int *value)
 
char * ngcbStr2Str (char *s1, const char *s2, size_t n)
 
int ngcbStr2UInt (const char *s, unsigned int *value)
 
int ngcbHex2Int (const char *s, int *value)
 
int ngcbHex2UInt (const char *s, unsigned int *value)
 
int ngcbFmt2Int (const char *s, int *value)
 
int ngcbFmt2UInt (const char *s, unsigned int *value)
 
int ngcbStr2Int16 (const char *s, short *value)
 
int ngcbStr2UInt16 (const char *s, unsigned short *value)
 
int ngcbHex2Int16 (const char *s, short *value)
 
int ngcbHex2UInt16 (const char *s, unsigned short *value)
 
int ngcbStr2Float (const char *s, float *value)
 
int ngcbStr2Double (const char *s, double *value)
 
int ngcbF2S (const char *s, const char *filter, char *v)
 
int ngcbF2Int (const char *s, const char *filter)
 
unsigned int ngcbF2UInt (const char *s, const char *filter)
 
int ngcbF2Double (const char *s, const char *filter, double *v)
 
int ngcbStr2Frac (const char *value, unsigned int n, uint64_t *v1, uint64_t *v2)
 
void ngcbRpcCopy (void *dest, const void *src, size_t size, size_t items, int how)
 
int ngcbStr2PayloadItem (const char *arg, unsigned char *payload, unsigned int max, int how, char *erms)
 
int ngcbStr2Payload (const char *cmd, unsigned char *payload, unsigned int max, int how, char *erms)
 
int ngcbStr2Rpc (const char *cmd, int *delay, int *target, int *req, unsigned int *size, char *erms)
 
int ngcbDiskMemCreate (const char *path, int idx, unsigned int size, unsigned int chunk, char *erms)
 
void ngcbDiskMemDelete (const char *path, int idx, unsigned int offset)
 
char * ngcbFitsStrip (char *buffer, size_t *size, int *bitPix, char *erms)
 
int ngcbCube2Ext (const char *fileName, const char *extName, int numBlocks, char *erms)
 
int ngcbSplitCube (const char *source, const char *target, int numBlocks, char *erms)
 
int ngcbCubeOpen (const char *fileName, ngcb_cube_t *cube, char *erms)
 
int ngcbCubeRead (ngcb_cube_t cube, void *buffer, int slice, char *erms)
 
int ngcbCubeRead32 (ngcb_cube_t cube, float *buffer, int slice, char *erms)
 
void ngcbCubeClose (ngcb_cube_t cube)
 
int ngcbKeyGetNext (char *fileBuffer, int fileLen, int *pos, int *line, const char *mask, char *key, char *keyVal, char *erms)
 
int ngcbKeySplit (char *key, int *nsplit, char **ksplit, int *val, char *erms)
 
int ngcbKeyIdx (char *key, int *nsplit, int *kval, char *erms)
 
int ngcbKeyMaskIdx (char *key, const char *mask)
 
int ngcbKeyGetVecInt (const char *keyVal, int *vec, char *erms)
 
int ngcbKeyGetVecFloat (const char *keyVal, float *vec, char *erms)
 
int ngcbKeyGetVecDouble (const char *keyVal, double *vec, char *erms)
 
void ngcbDiscardDetIdx (char *key)
 

Variables

int ngcbVerboseFlag
 

Detailed Description

Macro Definition Documentation

◆ _ngcb_cv

#define _ngcb_cv ( a)
Value:
#a

◆ _ngcb_tostr

#define _ngcb_tostr ( a)
Value:
#define _ngcb_cv(a)
Definition ngcb.h:105

◆ _vecsize

#define _vecsize ( x)
Value:
(sizeof(x)/sizeof(x[0]))

Macro to compute vector sizes

◆ NGCB_CODE_POS

#define NGCB_CODE_POS   __FILE__ ":" _ngcb_tostr(__LINE__)

Macro to log code position

◆ ngcb_fopen

#define ngcb_fopen ( p,
m )
Value:
fopen(p,m)

◆ ngcb_fseeko

#define ngcb_fseeko ( s,
o,
w )
Value:
fseeko(s,o,w)

◆ ngcb_ftello

#define ngcb_ftello ( s)
Value:
ftello(s)

◆ ngcb_ftruncate

#define ngcb_ftruncate ( s,
o )
Value:
ftruncate(s,o)

◆ ngcb_lseek

#define ngcb_lseek ( f,
o,
w )
Value:
lseek(f,o,w)

◆ ngcb_mmap

#define ngcb_mmap ( s,
l,
p,
fl,
fd,
o )
Value:
mmap(s,l,p,fl,fd,o)

◆ ngcb_open

#define ngcb_open ( p,
m )
Value:
open(p,m)

◆ ngcb_stat

#define ngcb_stat ( p,
s )
Value:
stat(p,s)

◆ ngcb_statvfs

#define ngcb_statvfs ( p,
s )
Value:
statvfs(p,s)

◆ ngcbABORTED

#define ngcbABORTED   1

operation aborted

◆ ngcbBIG_ENDIAN

#define ngcbBIG_ENDIAN   1

big endian

◆ ngcbDiffTime

#define ngcbDiffTime ( t1,
t2 )
Value:
((double)(t2.tv_sec - t1.tv_sec) + \
((double)(t2.tv_usec - t1.tv_usec)/1.0e6))

Time difference macro

◆ ngcbDiffTimeHR

#define ngcbDiffTimeHR ( t1,
t2 )
Value:
((double)(t2.tv_sec - t1.tv_sec) + \
((double)(t2.tv_nsec - t1.tv_nsec)/1.0e9))

Time difference macro (hi-res)

◆ ngcbDISCONNECT

#define ngcbDISCONNECT   -6

disconnect

◆ ngcbERR_ACCESS

#define ngcbERR_ACCESS   -5

missing access rights

◆ ngcbERR_SEVERE

#define ngcbERR_SEVERE   -4

severe error

◆ ngcbFAILURE

#define ngcbFAILURE   -1

operation failed

◆ ngcbFITS_BLOCK_LEN

#define ngcbFITS_BLOCK_LEN   (ngcbFITS_LINE_LEN * ngcbFITS_BLOCK_LINES)

FITS-block length in bytes

◆ ngcbFITS_BLOCK_LINES

#define ngcbFITS_BLOCK_LINES   36

Number of FITS lines per block

◆ ngcbFITS_KEY_SIZE

#define ngcbFITS_KEY_SIZE   48

Maximum FITS keyword size

◆ ngcbFITS_LINE_LEN

#define ngcbFITS_LINE_LEN   80

FITS line length

◆ ngcbFITS_TYPE_COMMENT

#define ngcbFITS_TYPE_COMMENT   7

comment

◆ ngcbFITS_TYPE_DOUBLE

#define ngcbFITS_TYPE_DOUBLE   3

64-bit floating point

◆ ngcbFITS_TYPE_FLOAT

#define ngcbFITS_TYPE_FLOAT   2

32-bit floating point

◆ ngcbFITS_TYPE_FREE

#define ngcbFITS_TYPE_FREE   6

free format

◆ ngcbFITS_TYPE_INT

#define ngcbFITS_TYPE_INT   1

32-bit integer

◆ ngcbFITS_TYPE_LOGICAL

#define ngcbFITS_TYPE_LOGICAL   5

logical

◆ ngcbFITS_TYPE_STRING

#define ngcbFITS_TYPE_STRING   4

string

◆ ngcbFmt

#define ngcbFmt ( ...)
Value:
(snprintf(__VA_ARGS__) < 0 ? abort() : (void)0)

Truncate formatted string

◆ ngcbLITTLE_ENDIAN

#define ngcbLITTLE_ENDIAN   0

little endian

◆ ngcbLog

#define ngcbLog ( ...)
Value:
do {if (ngcbVerboseFlag) fprintf(stdout, __VA_ARGS__);} while (0)
int ngcbVerboseFlag
Definition ngcbDebug.c:27

Verbose output macro

◆ ngcbMAX_KEY_LEN

#define ngcbMAX_KEY_LEN   256

maximum keyword length

◆ ngcbMAX_KEYELE_LEN

#define ngcbMAX_KEYELE_LEN   512

maximum keyword value length

◆ ngcbMEMCPY

#define ngcbMEMCPY   0

copy with memcpy

◆ ngcbNETCPY

#define ngcbNETCPY   1

copy to network byte order

◆ ngcbSCPY

#define ngcbSCPY   2

copy with byteswap

◆ ngcbSKIP

#define ngcbSKIP   -3

skip

◆ ngcbSUCCESS

#define ngcbSUCCESS   0

successful operation

◆ ngcbWARNING

#define ngcbWARNING   -2

a warning

◆ str2str

#define str2str ( s1,
s2,
n )
Value:
ngcbStr2Str(s1, s2, n)
char * ngcbStr2Str(char *s1, const char *s2, size_t n)
Definition ngcbString.c:177

NULL-terminated string copy

◆ USE

#define USE ( x)
Value:
do {(void)(x);} while (0)

Typedef Documentation

◆ ngcb_fct

typedef int(* ngcb_fct) (void)

Generic integer function type

◆ ngcb_off_t

typedef off_t ngcb_off_t

◆ ngcb_sig_t

typedef int(* ngcb_sig_t) (int how, const sigset_t *set, sigset_t *oset)

Signal-mask type

◆ ngcb_stat_t

typedef struct stat ngcb_stat_t

◆ ngcb_statvfs_t

typedef struct statvfs ngcb_statvfs_t

◆ ngcb_str128_t

typedef char ngcb_str128_t[128]

128 bytes string type

◆ ngcb_str256_t

typedef char ngcb_str256_t[256]

256 bytes string type

◆ ngcb_str32_t

typedef char ngcb_str32_t[32]

32 bytes string type

◆ ngcb_str512_t

typedef char ngcb_str512_t[512]

512 bytes string type

◆ ngcb_str64_t

typedef char ngcb_str64_t[64]

64 bytes string type

◆ ngcb_void_fct

typedef void(* ngcb_void_fct) (void)

Generic void function type

Function Documentation

◆ ngcbAddSec()

void ngcbAddSec ( struct timeval * t,
double seconds )

Add seconds to a time-stamp values. The value of seconds may be both positive or negative (or zero).

◆ ngcbAddTime()

void ngcbAddTime ( struct timeval t1,
struct timeval t2,
struct timeval * t3 )

Add two time-stamp values and stores the result of (t1 + t2) in t3.

◆ ngcbAddTimeFrac()

void ngcbAddTimeFrac ( uint64_t * sec,
uint64_t * nsec,
double t )

Add time (in seconds) to a fraction value (48 bit seconds and 30 bit nanoseconds + 16 bit fraction of nanoseconds).

◆ ngcbBin2Int()

int ngcbBin2Int ( const char * str)

Convert binary format string to signed integer. The string to be passed can contain up to 32 characters '0' or '1'.

◆ ngcbBin2UInt()

unsigned int ngcbBin2UInt ( const char * str)

Convert binary format string to an unsigned integer. The string to be passed can contain up to 32 characters '0' or '1'.

◆ ngcbCleanPath()

void ngcbCleanPath ( char * name)

Clean all occurrences of ./ and ../ in the path given by name.

◆ ngcbCleanSpace()

void ngcbCleanSpace ( char * s)

Remove all extra spaces in string.

◆ ngcbCube2Ext()

int ngcbCube2Ext ( const char * fileName,
const char * extName,
int numBlocks,
char * erms )

Move data-cube to FITS-extension.

◆ ngcbCubeClose()

void ngcbCubeClose ( ngcb_cube_t cube)

Close data cube.

◆ ngcbCubeOpen()

int ngcbCubeOpen ( const char * fileName,
ngcb_cube_t * cube,
char * erms )

Open data cube.

◆ ngcbCubeRead()

int ngcbCubeRead ( ngcb_cube_t cube,
void * buffer,
int slice,
char * erms )

Read slice from data cube.

◆ ngcbCubeRead32()

int ngcbCubeRead32 ( ngcb_cube_t cube,
float * buffer,
int slice,
char * erms )

Read slice from data cube and convert to 32-bit floating point format.

◆ ngcbDebugClose()

void ngcbDebugClose ( FILE * debugStream)

Close a debug stream. The function returns no value.

◆ ngcbDebugOpen()

FILE * ngcbDebugOpen ( char * erms)

Open a debug stream to a new x-terminal. The function returns a stream to be written to.

◆ ngcbDiscardDetIdx()

void ngcbDiscardDetIdx ( char * key)

Discards the DETi index from the keyword, if it is present.

◆ ngcbDiskMemCreate()

int ngcbDiskMemCreate ( const char * path,
int idx,
unsigned int size,
unsigned int chunk,
char * erms )

Create a disk memory mapping area in the directory pointed to by path. The size of the area is given in MBytes. The minimum size is 1 (MByte). When the size is larger than chunk then multiple chunks of size chunk + rest are created. When chunk is zero a default 1 GB chunk size is used. The idx defines a generic index to define the file names. The names of the files are:

"ngcb_swap<idx>_uid<uid>_<n>.mem" 

where n indicates the nth chunk and uid is the user id of the calling user. The chunks are filled with zeroes when being created. Chunks of valid size which are already existing will not be re-created.

◆ ngcbDiskMemDelete()

void ngcbDiskMemDelete ( const char * path,
int idx,
unsigned int offset )

Delete all disk memory files in the directory pointed to by path beginning with file name offset offset. When offset is zero then all files in the directory are deleted. The idx is a generic index to define the file-name.

◆ ngcbDiskSpace()

double ngcbDiskSpace ( const char * path,
char * erms )

Return the free diskspace (MBytes) in path.

◆ ngcbEndian()

int ngcbEndian ( void )

Return ngcbBIG_ENDIAN (1) in case the memory architecture is big endian, otherwise ngcbLITTLE_ENDIAN (0) is returned.

◆ ngcbExec()

int ngcbExec ( const char * host,
int * pid,
const char * cmd,
char * reply,
char * erms )

Execute a command on a host. The process id is returned (in pid). If the reply buffer passed to ngcbExec() is not NULL, then the process, which shall be started via these functions, should return a reply string with ngcbExecReply() after startup. A file descriptor to be used for ngcbExecReply() is automatically passed via the option [-fd n]. Processes, which do not handle this option, must be executed with the reply buffer set to NULL.

◆ ngcbExecDaemon()

int ngcbExecDaemon ( int bg)

Daemon process for remote process execution.

◆ ngcbExecDbg()

int ngcbExecDbg ( const char * host,
int * pid,
const char * cmd,
char * reply,
int port,
char * erms )

Same as ngcbExec() but enables debugging on given port

◆ ngcbExecInit()

int ngcbExecInit ( const char * host,
int * version,
char * erms )

Launch remote execution daemon on host. This function is automatically executed when ngcbExec()/ngcbKill() is called for the first time. The daemon will automatically die when the calling process exits.

◆ ngcbExecReply()

void ngcbExecReply ( int fd,
int success,
const char * reply )

Send reply message to calling application. Setting success to 1 indicates a succesful process start.

◆ ngcbExecShell()

void ngcbExecShell ( const char * shell)

Override default shell to be used for exec daemon remote execution

◆ ngcbExecutor()

int ngcbExecutor ( int argc,
char ** argv )

Retrieve remote execution handle from the command line options. The function returns a handle to be used for the ngcbExecReply().

◆ ngcbExecVersion()

int ngcbExecVersion ( const char * host,
char * erms )

Return the version of the remote exec daemon or -1 if the version cannot be retrieved.

◆ ngcbExecXt()

int ngcbExecXt ( const char * host,
int * pid,
const char * cmd,
char * reply,
const char * geom,
char * erms )

Same as ngcbExec() but executes the command in a new terminal

◆ ngcbExpand()

void ngcbExpand ( char * path)

Expand the path in case path was relative to current working directory.

◆ ngcbF2Double()

int ngcbF2Double ( const char * s,
const char * filter,
double * v )

Get filtered string option (double precision floating point).

◆ ngcbF2Int()

int ngcbF2Int ( const char * s,
const char * filter )

Get filtered string option (32-bit signed integer).

◆ ngcbF2S()

int ngcbF2S ( const char * s,
const char * filter,
char * v )

Get filtered string option.

◆ ngcbF2UInt()

unsigned int ngcbF2UInt ( const char * s,
const char * filter )

Get filtered string option (32-bit unsigned integer).

◆ ngcbFdCnt()

int ngcbFdCnt ( void )

Get number of currently open file descriptors.

◆ ngcbFileBufAlloc()

void * ngcbFileBufAlloc ( size_t size,
char * erms )

Allocate file buffer. The size is given in bytes but must be multiple of 256. The returned buffer is filled with zeros.

◆ ngcbFileBufFree()

void ngcbFileBufFree ( void * buffer)

Free file buffer.

◆ ngcbFileExists()

int ngcbFileExists ( const char * path)

Return 1 in case the path exists. Otherwise zero is returned.

◆ ngcbFileSize()

long int ngcbFileSize ( const char * fileName,
char * erms )

Return the size (bytes) of the given file. If the file does not exist or the file size could not be retrieved then the value -1 is returned.

◆ ngcbFilter()

double ngcbFilter ( ngcb_ma_t * f,
double value )

Return next filtered value (moving average).

◆ ngcbFilterDelete()

void ngcbFilterDelete ( ngcb_ma_t * f)

Delete moving average filter.

◆ ngcbFilterInit()

void ngcbFilterInit ( ngcb_ma_t * f,
int size )

Initialize moving average filter.

◆ ngcbFilterReset()

void ngcbFilterReset ( ngcb_ma_t * f)

Reset moving average filter.

◆ ngcbFindIndex()

int ngcbFindIndex ( const char * path,
int minIndex,
char * erms )

Searche all files in the parent directory of path, that match the pattern path*.fits, and returns the first free index in the wild-card larger than minIndex.

◆ ngcbFitsStrip()

char * ngcbFitsStrip ( char * buffer,
size_t * size,
int * bitPix,
char * erms )

Strip off the FITS-header from the buffer and return a pointer to the data. The size should be the original buffer size. When the function fails a NULL-pointer is returned. Otherwise size is updated to the size of the data buffer and bitPix returns the BITPIX-value from the FITS-header.

◆ ngcbFmt2Int()

int ngcbFmt2Int ( const char * s,
int * value )

Get 32-bit signed integer value from string, using 0x and 0b as format indicator.

◆ ngcbFmt2UInt()

int ngcbFmt2UInt ( const char * s,
unsigned int * value )

Get 32-bit unsigned signed integer value from string, using "0x" and "0b" as format indicator.

◆ ngcbGetFileExt()

const char * ngcbGetFileExt ( const char * fileName)

Return a pointer to a string containing the file extension (i.e. string including last '.') of fileName.

◆ ngcbGetMJD()

double ngcbGetMJD ( void )

Get the current time as Modified Julian Date.

◆ ngcbGetTime()

int ngcbGetTime ( struct timeval * t)

Store a time-stamp.

◆ ngcbGetUTC()

int ngcbGetUTC ( char * utc,
int precision )

Get the UTC in ISO format. If precision is greater than zero, then a fraction of seconds with precision digits is appended.

◆ ngcbHex2Int()

int ngcbHex2Int ( const char * s,
int * value )

Get 32-bit signed integer value from hexadecimal keyword string.

◆ ngcbHex2Int16()

int ngcbHex2Int16 ( const char * s,
short * value )

Get 16-bit signed integer value from hexadecimal keyword string.

◆ ngcbHex2UInt()

int ngcbHex2UInt ( const char * s,
unsigned int * value )

Get 32-bit unsigned integer value from hexadecimal keyword string.

◆ ngcbHex2UInt16()

int ngcbHex2UInt16 ( const char * s,
unsigned short * value )

Get 16-bit unsigned integer value from hexadecimal keyword string.

◆ ngcbInt2Bin()

void ngcbInt2Bin ( char * str,
int in )

Convert a signed integer value to binary format string.

◆ ngcbIsDir()

int ngcbIsDir ( const char * path)

Return 1 in case the path is a directory. Otherwise zero is returned.

◆ ngcbIsFloat()

int ngcbIsFloat ( const char * s)

Return 1, if the string represents a floating point number, otherwise zero is returned.

◆ ngcbKeyGetNext()

int ngcbKeyGetNext ( char * fileBuffer,
int fileLen,
int * pos,
int * line,
const char * mask,
char * key,
char * keyVal,
char * erms )

Read the next keyword from fileBuffer. The function returns -1 in case of error. If operation was successful zero is returned. If the end of the buffer has been reached the function returns a positive value(1).

◆ ngcbKeyGetVecDouble()

int ngcbKeyGetVecDouble ( const char * keyVal,
double * vec,
char * erms )

Get 64-bit floating point vector from keyword value keyVal. The function returna the length of the scanned vector. A negative return value indicates an error.

◆ ngcbKeyGetVecFloat()

int ngcbKeyGetVecFloat ( const char * keyVal,
float * vec,
char * erms )

Get 32-bit floating point vector from keyword value keyVal. The function returna the length of the scanned vector. A negative return value indicates an error.

◆ ngcbKeyGetVecInt()

int ngcbKeyGetVecInt ( const char * keyVal,
int * vec,
char * erms )

Get 32-bit integer vector vector from keyword value keyVal. The function returna the length of the scanned vector. A negative return value indicates an error.

◆ ngcbKeyIdx()

int ngcbKeyIdx ( char * key,
int * nsplit,
int * kval,
char * erms )

Get the index-array of all categories in the keyword. The function returns ngcbFAILURE in case of error. If operation was successful ngcbSUCCESS is returned.

◆ ngcbKeyMaskIdx()

int ngcbKeyMaskIdx ( char * key,
const char * mask )

Return the index after the first occurrence of mask in the keyword or -1 if mask is not found or no index is present.

◆ ngcbKeySplit()

int ngcbKeySplit ( char * key,
int * nsplit,
char ** ksplit,
int * val,
char * erms )

Split a keyword into its category parts. The function returns ngcbFAILURE in case of error. If operation was successful ngcbSUCCESS is returned.

◆ ngcbKill()

int ngcbKill ( const char * host,
int pid,
char * erms )

Send kill signal to process with process-id pid on the host given in hostName.

◆ ngcbLoadFile()

int ngcbLoadFile ( const char * fileName,
char * buffer,
size_t * size,
char * erms )

Read the (binary) data from the file and stores them into a buffer. A buffer of appropriate size has to be allocated by the calling instance.

◆ ngcbMapFile()

int ngcbMapFile ( const char * fileName,
char ** buffer,
size_t * size,
char * erms )

Open the file specified by fileName and map its content to a buffer. The size of the mapped buffer is computed by the function. The mapping is read-only. The function returns a file descriptor to be passed to the ngcbUnmapFile() which releases the buffer and then closes the file. In case of an error (-1) is returned and erms contains the detailed error message.

◆ ngcbMean16()

double ngcbMean16 ( unsigned short * a,
int n )

Compute mean-value of 16-bit unsigned integer array.

◆ ngcbMean32()

double ngcbMean32 ( int * a,
int n )

Compute mean-value of 32-bit signed integer array.

◆ ngcbMeanR32()

double ngcbMeanR32 ( float * a,
int n )

Compute mean-value of 32-bit floating point array.

◆ ngcbMeanR64()

double ngcbMeanR64 ( double * a,
int n )

Compute mean-value of 64-bit floating point array.

◆ ngcbMedian16()

unsigned short ngcbMedian16 ( unsigned short * a,
int n )

Compute median of 16-bit unsigned integer array.

◆ ngcbMedian32()

int ngcbMedian32 ( int * a,
int n )

Compute median of 32-bit signed integer array.

◆ ngcbMedianDelete()

void ngcbMedianDelete ( ngcb_rm_t * f)

Delete running median filter.

◆ ngcbMedianInit()

void ngcbMedianInit ( ngcb_rm_t * f,
int size )

Initialize running median filter.

◆ ngcbMedianR32()

float ngcbMedianR32 ( float * a,
int n )

Compute median of 32-bit floating point array.

◆ ngcbMedianReset()

void ngcbMedianReset ( ngcb_rm_t * f)

Reset running median filter.

◆ ngcbMicroSleep()

int ngcbMicroSleep ( int fd,
int waitTime )

Suspend process execution for waitTime microseconds. The sleep can be interrupted by writing to the file descriptor fd which will be closed in that case. If fd has a negative value then the sleep cannot be interrupted.

◆ ngcbMJD2UTC()

void ngcbMJD2UTC ( double mjd,
char * utc,
int precision )

Convert a Modified Julian Date into UTC in ISO format. If precision is greater than zero, then a fraction of seconds with precision digits is appended.

◆ ngcbMkDir()

int ngcbMkDir ( const char * path,
mode_t mode,
char * erms )

Attempt to create the directory given by the path argument. Parent directories will be created as needed. The parameter mode specifies the permissions to use. It is modified by the process's umask in the usual way: the permissions of the created directory are (mode & ~umask & 0777).

◆ ngcbParentDir()

void ngcbParentDir ( char * path,
const char * fileName )

Return in path the parent directory of the file specified by fileName.

◆ ngcbPathCmp()

int ngcbPathCmp ( const char * path1,
const char * path2 )

Return 1, if path1 and path2 refer to the same file. Otherwise zero is returned.

◆ ngcbPrint()

void ngcbPrint ( FILE * fd,
void * buffer,
size_t size,
int bitPix,
size_t max )

Print up to max elements of buffer

◆ ngcbProcName()

const char * ngcbProcName ( const char * path)

Return a pointer to a string containing the file/process name (i.e. string after last '/') of path.

◆ ngcbRead()

ssize_t ngcbRead ( int fd,
void * buffer,
size_t size,
char * erms )

Short wrapper function for socket and file-system read

◆ ngcbReadPerm()

int ngcbReadPerm ( const char * path)

Return 1 in case the path readable.

◆ ngcbRemoteFileClose()

void ngcbRemoteFileClose ( int fd)

Close a file-connection which has been opened with the ngcbRemoteFileOpen() function.

◆ ngcbRemoteFileDelete()

int ngcbRemoteFileDelete ( const char * host,
const char * fileName,
char * erms )

Delete a file residing on the given host.

◆ ngcbRemoteFileOpen()

int ngcbRemoteFileOpen ( const char * host,
const char * fileName,
size_t * size,
char * erms )

Return a read-only file descriptor to a file residing on host. The size returns the size of the file in bytes.

◆ ngcbReplaceEnv()

int ngcbReplaceEnv ( char * string,
char * erms )

Replace the environment variables in the given string.

◆ ngcbRound()

int ngcbRound ( double x)

Round argument to the nearest 32-bit integral value.

◆ ngcbRound64()

int64_t ngcbRound64 ( double x)

Round argument to the nearest 64-bit integral value

◆ ngcbRound64L()

int64_t ngcbRound64L ( long double x)

Round argument to the nearest 64-bit integral value

◆ ngcbRoundL()

int ngcbRoundL ( long double x)

Round argument to the nearest 32-bit integral value.

◆ ngcbRpcCopy()

void ngcbRpcCopy ( void * dest,
const void * src,
size_t size,
size_t items,
int how )

Copy RPC payload with or without byte swapping

◆ ngcbRunningMedian()

int ngcbRunningMedian ( ngcb_rm_t * f,
int value )

Return next filtered value (running median).

◆ ngcbSkipFd()

int ngcbSkipFd ( FILE * stream)

Skip the contents of the stream until a new-line character was read. The function returns the number of skipped characters.

◆ ngcbSleep()

int ngcbSleep ( int fd,
int waitTime )

Suspend process execution for waitTime seconds. The sleep can be interrupted by writing to fd which will be closed in that case. If the termSock has a negative value, the sleep cannot be interrupted.

◆ ngcbSplitCube()

int ngcbSplitCube ( const char * source,
const char * target,
int numBlocks,
char * erms )

Split data-cube into FITS-extensions per chip.

◆ ngcbStr2Arg()

void ngcbStr2Arg ( char * s,
int * argc,
char ** argv )

Convert a string to command line arguments.

◆ ngcbStr2Double()

int ngcbStr2Double ( const char * s,
double * value )

Get double precision floating point value from keyword string.

◆ ngcbStr2Float()

int ngcbStr2Float ( const char * s,
float * value )

Get single precision floating point value from string.

◆ ngcbStr2Frac()

int ngcbStr2Frac ( const char * value,
unsigned int n,
uint64_t * v1,
uint64_t * v2 )

Fraction with binary fixed-point after n digits

◆ ngcbStr2Int()

int ngcbStr2Int ( const char * s,
int * value )

Get 32-bit signed integer value from decimal string.

◆ ngcbStr2Int16()

int ngcbStr2Int16 ( const char * s,
short * value )

Get 16-bit signed integer value from decimal string.

◆ ngcbStr2Payload()

int ngcbStr2Payload ( const char * cmd,
unsigned char * payload,
unsigned int max,
int how,
char * erms )

Convert formatted command string to payload

◆ ngcbStr2PayloadItem()

int ngcbStr2PayloadItem ( const char * arg,
unsigned char * payload,
unsigned int max,
int how,
char * erms )

Convert formatted argument string to payload item

◆ ngcbStr2Rpc()

int ngcbStr2Rpc ( const char * cmd,
int * delay,
int * target,
int * req,
unsigned int * size,
char * erms )

Get delay (microseconds), target, request and payload size from command string

◆ ngcbStr2Str()

char * ngcbStr2Str ( char * s1,
const char * s2,
size_t n )

Copy n characters of one string to another (null terminated).

◆ ngcbStr2UInt()

int ngcbStr2UInt ( const char * s,
unsigned int * value )

Get 32-bit unsigned integer value from decimal keyword string.

◆ ngcbStr2UInt16()

int ngcbStr2UInt16 ( const char * s,
unsigned short * value )

Get 16-bit unsigned integer value from decimal keyword string.

◆ ngcbStrPut()

void ngcbStrPut ( char * s1,
const char * s2 )

Put string s2 ahead of string s1.

◆ ngcbSubTime()

void ngcbSubTime ( struct timeval t1,
struct timeval t2,
struct timeval * t3 )

Subtracts two time-stamp values and stores the result of (t2 - t1) in t3.

◆ ngcbSwap2()

void ngcbSwap2 ( void * buffer,
size_t length )

Change the byte order of the 16-bit numbers in buffer from 1,2 to 2,1. length is the number of 16-bit items in the buffer.

◆ ngcbSwap4()

void ngcbSwap4 ( void * buffer,
size_t length )

Change the byte order of the 32-bit numbers in buffer from 1,2,3,4 to 4,3,2,1. length is the number of 32-bit items (integer, single precision float) in the buffer.

◆ ngcbSwap8()

void ngcbSwap8 ( void * buffer,
size_t length )

Change the byte order of the 64-bit numbers in buffer from 1,2,3,4,5,6,7,8 to 8,7,6,5,4,3,2,1. length is the number of 64-bit items (64-bit integer, double precision float) in the buffer.

◆ ngcbTaiOffset()

int ngcbTaiOffset ( )

Get TAI offset (seconds)

◆ ngcbTime2MJD()

double ngcbTime2MJD ( struct timeval t)

Return the Modified Julian Date of a time-stamp.

◆ ngcbTime2UTC()

void ngcbTime2UTC ( struct timeval t,
char * utc,
int precision )

Convert the time-stamp into ISO-format. If precision is greater than zero, then a fraction of seconds with precision digits is appended.

◆ ngcbTimeFrac2Str()

void ngcbTimeFrac2Str ( char * value,
uint64_t sec,
uint64_t nsec )

Convert a time given in seconds and 30 bit nanoseconds + 16 bit fraction of nanoseconds to a string representing seconds in a high precision floating point number.

◆ ngcbToLower()

void ngcbToLower ( char * s)

Convert all characters in string to lower case.

◆ ngcbToUpper()

void ngcbToUpper ( char * s)

Convert all characters in string to upper case.

◆ ngcbTrimSpace()

void ngcbTrimSpace ( char * s)

Remove leading and trailing spaces in string.

◆ ngcbUInt2Bin()

void ngcbUInt2Bin ( char * str,
unsigned int in )

Convert an unsigned integer value to binary format string.

◆ ngcbUnmapFile()

void ngcbUnmapFile ( int fd,
char * buffer,
size_t size )

Unmap the buffer of the given size and then close the file defined by the file descriptor fd. If the buffer is a NULL pointer or size is less or equal to zero or fd is negative then no action is taken. The function returns no value.

◆ ngcbUTC2MJD()

double ngcbUTC2MJD ( const char * utc)

Convert an UTC time string in ISO format into Modified Julian Date format. A return value of 0.0 indicates a conversion error.

◆ ngcbWatchdogAddCmd()

void ngcbWatchdogAddCmd ( FILE * wd,
const char * host,
const char * cmd )

Add a command to the watchdog instruction list. The command will be executed when the calling process terminates abnormally.

◆ ngcbWatchdogAddProc()

void ngcbWatchdogAddProc ( FILE * wd,
const char * host,
int pid )

Add a process to the watchdog kill-list. When the calling process terminates abnormally the watchdog will kill all processes in the list.

◆ ngcbWatchdogClearCmd()

void ngcbWatchdogClearCmd ( FILE * wd,
const char * host )

Clear the watchdog instruction list for host. If host is a NULL-pointer then the complete instruction list is cleared.

◆ ngcbWatchdogClearProc()

void ngcbWatchdogClearProc ( FILE * wd,
const char * host )

Clear the watchdog kill-list for host.

◆ ngcbWatchdogClose()

void ngcbWatchdogClose ( FILE * wd)

Close watchdog connection and terminate the watchdog process. The function returns no value.

◆ ngcbWatchdogDbWrite()

void ngcbWatchdogDbWrite ( FILE * wd,
const char * host,
const char * attr,
const char * value )

Add a database attribute update to the watchdog execution list. The attribute will be set to the given value when the calling process terminates abnormally.

◆ ngcbWatchdogOpen()

FILE * ngcbWatchdogOpen ( int verbose,
char * erms )

Open a watchdog connection. The function returns a stream to be written to. If the verbose flag is greater than zero then the watchdog process is launched in verbose mode in a new terminal.

◆ ngcbWatchdogRemoveCmd()

void ngcbWatchdogRemoveCmd ( FILE * wd,
const char * host,
const char * cmd )

Remove a command from the watchdog instruction list.

◆ ngcbWatchdogRemoveProc()

void ngcbWatchdogRemoveProc ( FILE * wd,
const char * host,
int pid )

Removes a process from the watchdog kill-list. If host is a NULL-pointer then the complete kill-list is cleared.

◆ ngcbWin2File()

int ngcbWin2File ( FILE * fd,
const char * buffer,
size_t fx,
size_t fy,
int bitPix,
size_t sx,
size_t sy,
size_t nx,
size_t ny,
int rot,
char * erms )

Cut window (sx, sy, nx, ny) from a frame buffer (dimension fx, fy) and write it directly to a FILE, which must have been opened before. bitPix specifies the number of bits per pixel. rot gives a rotation angle in degrees to rotate the data clockwise before storing to file.

◆ ngcbWrite()

ssize_t ngcbWrite ( int fd,
const void * buffer,
size_t size,
char * erms )

Short wrapper function for socket and file-system write

◆ ngcbWriteFile()

int ngcbWriteFile ( const char * fileName,
const char * buffer,
size_t size,
char * erms )

Create the file specified in fileName and writes size bytes of the buffer to the file.

◆ ngcbWritePerm()

int ngcbWritePerm ( const char * path)

Return 1 in case the path writeable.

Variable Documentation

◆ ngcbVerboseFlag

int ngcbVerboseFlag
extern

Global verbose flag for all basic functions