API Reference

configuration.h

The configuration module reponsible for managing the configuration of xy. Any change to xy’s runtime configuration (RC) file will cause the configuration to be reloaded (see config_reinit()).

CONFIG

The type made available after a call to config_init(). It contains all the necessary configuration options xy uses while running.

CONFIG * config_init()

Initializes xy’s configuration. Returns the configuration or NULL on failure. This function makes CONFIG available for use.

void config_terminate()

The configuration module’s shutdown hook.

void write_default_config()

Writes the default xy configuration to the xy runtime configuration path.

void config_reinit()

Reinitializes the configuration from the xy runtime configuration path.

util.h

A collection of utility functions meant to stand alone from other xy modules.

char * rc_path()

Returns the path of xy’s runtime configuration. The returned string should be freed by the caller.

bool streq(const char *, const char *)

Returns true if the strings are equal or null, false otherwise.

char * trim(char *)

Removes leading and trailing whitespace from the string and returns a pointer starting from the first non-whitespace character. The returned string is contained in the same memory as the argument.

Example:

char *conststr = " test string ";
char *dup = strdup(conststr);
char *trimmed = trim(dup); // trimmed: "test string"
free(dup);
void dump_stack(uint num_frames)

Dumps num_frames stack frames to stderr.

void parse_command(char *cmd, char **argv)

Tokenizes cmd by spaces into tokens placed in argv.

Example:

char *command = "some string here";
char *dup = strdup(command);
char *argv[3];
parse_command(dup, argv);
// argv[0]: "some"
// argv[1]: "string"
// argv[2]: "here"
free(dup);
void exec(const char * cmd)

Executes the supplied command by calling execvp. The command will be parsed before the call is made (see parse_command()).

inotify.h

The inotify module. XY uses the inotify module to react to changes occurring on the filesystem.

types

in_fd

The inotify file descriptor made available after a call to xy_inotify_init(). This file descriptor is suitable for system calls like select and epoll.

functions

void xy_inotify_init()

Initializes xy’s inotify module. This function makes in_fd available for use, which may be -1 on failure.

void xy_inotify_reinit()

Reinitializes the inotify module. This function makes a new in_fd available for use.

void xy_inotify_terminate()

The inotify module’s shutdown hook.

void xy_inotify_read()

Drains the inotify event queue of all events.