MAOS
Multithreaded Adaptive Optics Simulator
readcfg.h File Reference

Macros

#define format2key
 

Functions

void open_config (const char *fn, const char *prefix, int priority)
 
void close_config (const char *format,...)
 
int readcfg_peek (const char *format,...)
 
int readcfg_peek_n (const char *format,...)
 
int readcfg_peek_priority (const char *format,...)
 
void readcfg_ignore (const char *format,...)
 
char * readcfg_str (const char *format,...)
 
int readcfg_int (const char *format,...)
 
real readcfg_dbl (const char *format,...)
 
int readcfg_strarr (char ***res, int len, int relax, const char *format,...)
 
int readcfg_intarr (int **ret, int len, int relax, const char *format,...)
 
int readcfg_dblarr (real **ret, int len, int relax, const char *format,...)
 
dmatreadstr_dmat (int n, int relax, const char *key, const char *str)
 
dmatreadcfg_dmat (int n, int relax, const char *format,...)
 
lmatreadcfg_lmat (int n, int relax, const char *format,...)
 
dcellreadcfg_dcell (const char *format,...)
 

Detailed Description

Routines to read .conf type config files. Each entry is composed of a key and a value. The entries are maintained in a hash table. Each entry can be retrieved from the key.

Macro Definition Documentation

◆ format2key

#define format2key
Value:
char key[512]; \
va_list ap; \
va_start(ap,format); \
vsnprintf(key,sizeof(key), format, ap); \
va_end(ap)

Function Documentation

◆ open_config()

void open_config ( const char *  config_in,
const char *  prefix,
int  priority 
)

Start the read config process by opening .conf files and fill the entries in a hash table. A key has a priority or 0 or higher. A new key with same or higher priority can override previous entry. priority is 0 for default configurations. -1 indicates optional configuration file that fails silently.

Parameters
[in]config_inThe .conf file to read
[in]prefixif not NULL, prefix the key with this.
[in]priorityPriorities of keys.

◆ close_config()

void close_config ( const char *  format,
  ... 
)

Save all configs to file and check for unused config options.

◆ readcfg_peek()

int readcfg_peek ( const char *  format,
  ... 
)

Check whether a have a record of a key.

◆ readcfg_peek_n()

int readcfg_peek_n ( const char *  format,
  ... 
)

Check the size of an array input

◆ readcfg_peek_priority()

int readcfg_peek_priority ( const char *  format,
  ... 
)

Check whether the record is overriden by user supplied conf files.

◆ readcfg_ignore()

void readcfg_ignore ( const char *  format,
  ... 
)

Ignore an entry and do not warn if it does not exist.

◆ readcfg_str()

char* readcfg_str ( const char *  format,
  ... 
)

Obtain a string value from the key.

◆ readcfg_int()

int readcfg_int ( const char *  format,
  ... 
)

Read integer

◆ readcfg_dbl()

real readcfg_dbl ( const char *  format,
  ... 
)

Read real

◆ readcfg_strarr()

int readcfg_strarr ( char ***  ret,
int  len,
int  relax,
const char *  format,
  ... 
)

Read string array of len elements

◆ readcfg_intarr()

int readcfg_intarr ( int **  ret,
int  len,
int  relax,
const char *  format,
  ... 
)

Read integer array of len elements

◆ readcfg_dblarr()

int readcfg_dblarr ( real **  ret,
int  len,
int  relax,
const char *  format,
  ... 
)

Read integer array of len elements

◆ readstr_dmat()

dmat* readstr_dmat ( int  n,
int  relax,
const char *  key,
const char *  str 
)

Read as a dmat. It can be a file name or an array.

Parameters
[in]nNumber of elements requested
[in]relax1: allow fewer values and fill the rest
[in]keythe key that needs the value.
[in]strinput

◆ readcfg_dmat()

dmat* readcfg_dmat ( int  n,
int  relax,
const char *  format,
  ... 
)

Read as a dmat. It can be a file name or an array.

◆ readcfg_lmat()

lmat* readcfg_lmat ( int  n,
int  relax,
const char *  format,
  ... 
)

Read as an lmat.

◆ readcfg_dcell()

dcell* readcfg_dcell ( const char *  format,
  ... 
)

Read dcell