Crinit -- Configurable Rootfs Init
|
Header related to handling of runtime commands received via the notification/service interface. More...
Go to the source code of this file.
Classes | |
struct | crinitRtimCmd_t |
Macros | |
#define | CRINIT_RTIMCMD_SHDN_THREAD_STACK_SIZE (PTHREAD_STACK_MIN + 112 * 1024) |
#define | CRINIT_RTIMCMD_RES_OK "RES_OK" |
Value of first argument in a positive (successful) response message. More... | |
#define | CRINIT_RTIMCMD_RES_ERR "RES_ERR" |
Value of first argument in a negative (unsuccessful) response message. More... | |
Typedefs | |
typedef struct crinitRtimCmd_t | crinitRtimCmd_t |
Functions | |
int | crinitBuildRtimCmd (crinitRtimCmd_t *c, crinitRtimOp_t op, size_t argc,...) |
int | crinitDestroyRtimCmd (crinitRtimCmd_t *c) |
int | crinitParseRtimCmd (crinitRtimCmd_t *out, const char *cmdStr) |
int | crinitRtimCmdToMsgStr (char **out, size_t *outLen, const crinitRtimCmd_t *cmd) |
int | crinitExecRtimCmd (crinitTaskDB_t *ctx, crinitRtimCmd_t *res, const crinitRtimCmd_t *cmd) |
Header related to handling of runtime commands received via the notification/service interface.
#define CRINIT_RTIMCMD_RES_ERR "RES_ERR" |
Value of first argument in a negative (unsuccessful) response message.
#define CRINIT_RTIMCMD_RES_OK "RES_OK" |
Value of first argument in a positive (successful) response message.
#define CRINIT_RTIMCMD_SHDN_THREAD_STACK_SIZE (PTHREAD_STACK_MIN + 112 * 1024) |
Stack size for the shutdown/reboot handling thread.
typedef struct crinitRtimCmd_t crinitRtimCmd_t |
Structure holding a command or response message with its crinitRtimOp_t opcode and arguments array.
int crinitBuildRtimCmd | ( | crinitRtimCmd_t * | c, |
crinitRtimOp_t | op, | ||
size_t | argc, | ||
... | |||
) |
Create an crinitRtimCmd_t from an opcode and an argument list.
Will allocate memory for the argument string array which should be freed using crinitDestroyRtimCmd() when no longer needed.
c | The crinitRtimCmd_t to build. |
op | The opcode of the command or response. |
argc | The number of arguments to the command/response. |
... | List of argc arguments of type const char* . |
int crinitDestroyRtimCmd | ( | crinitRtimCmd_t * | c | ) |
Free memory in an crinitRtimCmd_t allocated by crinitBuildRtimCmd() or crinitParseRtimCmd().
Will free the memory for the argument array in the structure.
c | The crinitRtimCmd_t from which the memory should be freed. |
int crinitExecRtimCmd | ( | crinitTaskDB_t * | ctx, |
crinitRtimCmd_t * | res, | ||
const crinitRtimCmd_t * | cmd | ||
) |
Executes an crinitRtimCmd_t if it contains a valid command.
For the implementations of the different possible commands see rtimcmd.c.
ctx | Pointer to the crinitTaskDB_t the command shall be executed on. |
res | Result/response output. |
cmd | The command to execute. |
int crinitParseRtimCmd | ( | crinitRtimCmd_t * | out, |
const char * | cmdStr | ||
) |
Parses a string into an crinitRtimCmd_t.
The string must be of the form <OPCODE_STRING>\nARG1\n...\nARGn
. The mapping of an opcode to a string representation is done in rtimopmap.h. crinitRtimCmdToMsgStr() can be used to obtain such a string from an crinitRtimCmd_t.
Will allocate memory for the argument array inside the output command which should be freed using crinitDestroyRtimCmd().
out | The crinitRtimCmd_t to create. |
cmdStr | The string to parse. |
int crinitRtimCmdToMsgStr | ( | char ** | out, |
size_t * | outLen, | ||
const crinitRtimCmd_t * | cmd | ||
) |
Generates a string representation of an crinitRtimCmd_t.
The generated string will be in a format parse-able by crinitParseRtimCmd(). Memory for the string will be allocated using malloc() and should be freed using free() once no longer used.
out | Pointer to the output string. |
outLen | Size of the output string including the terminating zero. |
cmd | The crinitRtimCmd_t to generate the string from. |