|
howm
howm
|
Everything required to parse, interpret and respond to messages that are sent over IPC. More...
#include <sys/socket.h>#include <sys/un.h>#include <stdbool.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <unistd.h>#include "client.h"#include "helper.h"#include "howm.h"#include "ipc.h"#include "layout.h"#include "monitor.h"#include "op.h"#include "scratchpad.h"#include "types.h"#include "workspace.h"Macros | |
| #define | CALL_INT(func, arg, lower, upper) |
| #define | CALL_WORKSPACE(func, arg, lower, upper) |
| #define | SET_INT(opt, arg, lower, upper) |
| #define | SET_BOOL(opt, arg) |
| #define | SET_COLOUR(opt, arg) |
Enumerations | |
| enum | msg_type { MSG_FUNCTION = 1, MSG_CONFIG } |
Functions | |
| static char ** | ipc_process_args (char *msg, int len, int *err) |
| Accepts a char array and convert it into an array of strings. More... | |
| static int | ipc_arg_to_int (char *arg, int *err, int lower, int upper) |
| Convert a numerical string into a decimal value, such as "12" becoming 12. More... | |
| static int | ipc_process_function (char **args) |
| Receive a char array from a UNIX socket and subsequently call a function, passing the args from within msg. More... | |
| static int | ipc_process_config (char **args) |
| Process a config message. If the config option isn't recognised, set err to IPC_ERR_NO_CONFIG. More... | |
| static bool | ipc_arg_to_bool (char *arg, int *err) |
| Convert an argument to a boolean. More... | |
| int | ipc_init (void) |
| Open a socket and return it. More... | |
| void | ipc_cleanup (void) |
| Delete the UNIX socket file. More... | |
| int | ipc_process (char *msg, int len) |
| Process a message depending on its type - a config message or a function call message. More... | |
Everything required to parse, interpret and respond to messages that are sent over IPC.
| #define CALL_INT | ( | func, | |
| arg, | |||
| lower, | |||
| upper | |||
| ) |
| #define CALL_WORKSPACE | ( | func, | |
| arg, | |||
| lower, | |||
| upper | |||
| ) |
| #define SET_BOOL | ( | opt, | |
| arg | |||
| ) |
| #define SET_COLOUR | ( | opt, | |
| arg | |||
| ) |
| #define SET_INT | ( | opt, | |
| arg, | |||
| lower, | |||
| upper | |||
| ) |
| enum msg_type |
|
static |
Convert an argument to a boolean.
t and 1 are considered true, f and 0 are considered false.
| arg | A string containing the argument. |
| err | Where an error code should be stored. |
|
static |
Convert a numerical string into a decimal value, such as "12" becoming 12.
Minus signs are handled. It is assumed that a two digit number won't start with a zero. Args with more than two digits will not be accepted, nor will args that aren't numerical.
| arg | The string to be converted. |
| err | Where errors are reported. |
| lower | The lower bound for the returned value. Note: This is inclusive |
| upper | The upper bound for the returned value. Note: This is inclusive |
| void ipc_cleanup | ( | void | ) |
Delete the UNIX socket file.
| int ipc_init | ( | void | ) |
Open a socket and return it.
If a socket path is defined in the env variable defined as ENV_SOCK_VAR then use that - else use DEF_SOCK_PATH.
| int ipc_process | ( | char * | msg, |
| int | len | ||
| ) |
Process a message depending on its type - a config message or a function call message.
| msg | A buffer containing the message sent by cottage. |
| len | The length of the message. |
|
static |
Accepts a char array and convert it into an array of strings.
msg is split into strings (delimited by a null character) and placed in an array. err is set with a corresponding error (such as args too few args), or nothing.
XXX: args must be freed by the caller.
| msg | A char array that is read from a UNIX socket. |
| len | The length of data in msg. |
| err | Where any errors will be stored. |
|
static |
Process a config message. If the config option isn't recognised, set err to IPC_ERR_NO_CONFIG.
| args | An array of strings representing the args. |
|
static |
Receive a char array from a UNIX socket and subsequently call a function, passing the args from within msg.
| args | The args (as strings). |