![]() |
MAOS
Multithreaded Adaptive Optics Simulator
|
Data Structures | |
struct | argopt_t |
Macros | |
#define | strdup mystrdup /*our strdup handles NULL correctly, and talk to mem.c */ |
#define | strndup mystrndup |
#define | snprintf mysnprintf /*our snprintf avoids the truncation error by checking the returned size. */ |
#define | default_color(i) default_color_table[i%11] |
Functions | |
char * | mydirname (const char *fn) |
int | check_suffix (const char *fn, const char *suffix) |
int | copyfile (const char *src, const char *dest) |
char * | argv2str (int argc, const char *argv[], const char *delim) |
void | print_file (const char *fnin) |
time_t | myclocki (void) |
double | myclockd (void) |
const char * | myasctime (time_t at) |
char * | strtime_pid (void) |
const char * | myhostname (void) |
char * | mygetcwd (void) |
char * | myabspath (const char *path) |
int | mysymlink (const char *source, const char *dest) |
int | mylink (const char *source, const char *dest) |
int | exist (const char *fn) |
void | touch (const char *format,...) |
int | isdir (const char *fn) |
int | isfile (const char *fn) |
int | islink (const char *fn) |
int | issock (int fd) |
size_t | flen (const char *fn) |
time_t | fmtime (const char *fn) |
char * | stradd (const char *a,...) |
char * | strnadd (int argc, const char *argv[], const char *delim) |
char * | expand_filename (const char *fn) |
void | remove_file_older (const char *fndir, int level, long sec) |
void | mymkdir (const char *format,...) |
int | mystrcmp (const char *a, const char *b) |
char * | mystrndup (const char *A, size_t len) |
void | cloexec (int fd) |
void | mysleep (double sec) |
int | mypause (int fd1, int fd2) |
long | available_space (const char *path) |
char * | mystrdup (const char *A) |
int | mysnprintf (char *__restrict str, size_t size, const char *__restrict format,...) |
replaces snprintf to check for return and print a warning if there is truncation. | |
void | mystrrep (char *str, const char *prefix, const char *substitute) |
void | parse_argopt (char *cmds, argopt_t *options) |
void | set_realtime (int icpu, int niceness) |
void | free_strarr (char **str, int n) |
void | print_version (void) |
misc routines.
struct argopt_t |
Data Fields | ||
---|---|---|
const char * | name |
The long name |
char | key |
The short name |
int | type |
The type of result expected |
int | valtype |
The type of input expected: 0: The key does not need value; 1: The key needs value; 2: The key accepts an array of values. |
int | isfun |
Whether val indicate a function pointer 0: The address to put the return results. 1: A function pointer to call. |
void * | val |
The address to put the return result. |
int * | nval |
If val is array, this is the counter. |
char * mydirname | ( | const char * | fn | ) |
Obtain the dirname of a path. See mybasename().
Convert argc, argv to a single string, prefixed by the current directory.
time_t myclocki | ( | void | ) |
Get current time in seconds as an integer.
double myclockd | ( | void | ) |
Get current time in nano-second resolution.
const char * myasctime | ( | time_t | at | ) |
Get current time in ascii string for easy print. The string contains spaces and is not suitable to use in filename. The returned string should not be modified.
char * strtime_pid | ( | void | ) |
Get furrent time in ascii string that doesn't contain spaces. Suitable for use in filenames. The returnned string must be freed.
char * mygetcwd | ( | void | ) |
Get current directory. The returnned string must be freed.
char * myabspath | ( | const char * | path | ) |
Translate a path into absolute path. The caller shall free the returned string.
int exist | ( | const char * | fn | ) |
Test whether a file exists.
int isdir | ( | const char * | fn | ) |
Test whether fn is directory
int isfile | ( | const char * | fn | ) |
Test whether fn is ordinary file
int islink | ( | const char * | fn | ) |
Test whether fn is a symbolic link
int issock | ( | int | fd | ) |
Test whether fd is a socket
time_t fmtime | ( | const char * | fn | ) |
Return the modification time of the file
char * stradd | ( | const char * | a, |
... | |||
) |
Concatenate many strings. Argument list must end with NULL.
Concatenate many strings, like stradd, but arguments are an array of char*
char * expand_filename | ( | const char * | fn | ) |
translate a filename into absolute file name that starts with /
Remove files that are older than sec seconds in folder fndir. If sec==0, remove everything.
Compare two strings upto the length of b. if length of a is less than b, return false. 1 means not equal.
Duplicate a string. Check for NULL. Do not call strndup to avoid recursive deadlock.
void cloexec | ( | int | fd | ) |
Make the fd close on exec.
void mysleep | ( | double | sec | ) |
wrap of nanosleep
int mypause | ( | int | fd1, |
int | fd2 | ||
) |
Pause execution and listen input from fd1 and/or fd2 for continuation. Returns new pause flag.
fd1 | first file no, usually 0 for stdin |
fd2 | second file no, usually created from a pipe t |
char * mystrdup | ( | const char * | A | ) |
declare strdup so my memory mangement mem.c is happy when DEBUG=1. Handles NULL pointer correctly. Do not call strdup to avoid recursive deadlock.
Parse command line arguments. The remaining string contains whatever is not yet parsed. This is more relaxed than the built in getopd
void set_realtime | ( | int | icpu, |
int | niceness | ||
) |
Set scheduling priorities for the process to enable real time behavior.