InfinotedUtil

InfinotedUtil — Miscellaneous helper functions.

Stability Level

Unstable, unless otherwise indicated

Synopsis

#include <infinoted/infinoted-util.h>

gboolean            infinoted_util_create_dirname       (const gchar *path,
                                                         GError **error);
void                infinoted_util_set_errno_error      (GError **error,
                                                         int save_errno,
                                                         const char *prefix);
void                infinoted_util_daemon_set_global_pid_file_proc
                                                        (void);
void                infinoted_util_daemon_set_local_pid_file_proc
                                                        (void);
int                 infinoted_util_daemon_pid_file_kill (int sig);

Description

This section contains a few helper functions that are used in the infinoted implementation and are exposed to the plugin interface for convenience of plugin developers.

Details

infinoted_util_create_dirname ()

gboolean            infinoted_util_create_dirname       (const gchar *path,
                                                         GError **error);

Creates directories leading to the given path. Does not create a directory for the last component of the path, assuming that it is a filename that you are going to write into that directory later.

path :

The filename to create a path to.

error :

Location to store error information, if any.

Returns :

TRUE on success, or FALSE on error in which case error is set.

infinoted_util_set_errno_error ()

void                infinoted_util_set_errno_error      (GError **error,
                                                         int save_errno,
                                                         const char *prefix);

Sets error to save_errno with domain ERRNO_ERROR. If prefix is non-NULL, prefix is prefixed to error's message, obtained by strerror().

error :

A pointer to a GError pointer, or NULL.

save_errno :

An errno variable.

prefix :

A prefix string, or NULL.

infinoted_util_daemon_set_global_pid_file_proc ()

void                infinoted_util_daemon_set_global_pid_file_proc
                                                        (void);

When attempting to read or write the PID file use the global file.


infinoted_util_daemon_set_local_pid_file_proc ()

void                infinoted_util_daemon_set_local_pid_file_proc
                                                        (void);

When attempting to read or write the PID file use the local file which is in the owner's home directory.


infinoted_util_daemon_pid_file_kill ()

int                 infinoted_util_daemon_pid_file_kill (int sig);

This is a thin wrapper for daemon_pid_file_kill() which uses daemon_pid_file_kill_wait() if available with a timeout of 5 seconds.

sig :

The signal to send to the daemon process.

Returns :

0 if the signal was sent or nonzero otherwise.