Crinit -- Configurable Rootfs Init
rtimopmap.c File Reference

(2023-08-02, commit: 9434b31)

Implementation of functions related to the runtime command opcode map. More...

#include "rtimopmap.h"
#include <stdlib.h>
#include <string.h>
#include "logio.h"
Include dependency graph for rtimopmap.c:

Macros

#define CRINIT_RTIMOPMAP_ELEMENTS   (sizeof(crinitRtimOps) / sizeof(crinitRtimOpMap_t))
 

Functions

static size_t crinitDelimitedStrlen (const char *str)
 
void crinitRtimOpMapDebugPrintAll (void)
 
int crinitRtimOpGetByOpStr (crinitRtimOp_t *out, const char *opStr)
 
int crinitOpStrGetByRtimOp (const char **out, crinitRtimOp_t opCode)
 

Variables

const crinitRtimOpMap_t crinitRtimOps [] = {crinitGenOpMap(crinitGenOpStruct)}
 

Detailed Description

Implementation of functions related to the runtime command opcode map.

Macro Definition Documentation

◆ CRINIT_RTIMOPMAP_ELEMENTS

#define CRINIT_RTIMOPMAP_ELEMENTS   (sizeof(crinitRtimOps) / sizeof(crinitRtimOpMap_t))

The number of elements in the generated map.

Function Documentation

◆ crinitDelimitedStrlen()

static size_t crinitDelimitedStrlen ( const char *  str)
inlinestatic

Gives the length of a string, delimited either by terminating zero or CRINIT_RTIMCMD_ARGDELIM.

Parameters
strThe string. Must be at least one of: null-terminated CRINIT_RTIMCMD_ARGDELIM-terminated.
Returns
The length of str, not including the delimiting character (or the terminating zero).

◆ crinitOpStrGetByRtimOp()

int crinitOpStrGetByRtimOp ( const char **  out,
crinitRtimOp_t  opCode 
)

Given an crinitRtimOp_t opcode, obtain its string representation.

The returned point points to static memory that shall not be changed.

Parameters
outReturn pointer for the string representation.
opCodeThe opcode.
Returns
0 on success, -1 otherwise

◆ crinitRtimOpGetByOpStr()

int crinitRtimOpGetByOpStr ( crinitRtimOp_t out,
const char *  opStr 
)

Given its string representation, find the correct opcode.

Parameters
outReturn pointer for the opcode.
opStrThe string representaiton.
Returns
0 on success, -1 otherwise

◆ crinitRtimOpMapDebugPrintAll()

void crinitRtimOpMapDebugPrintAll ( void  )

List available opcodes.

Will print the full list of available opcodes in their string representation and the corresponding numerical opcode. Output will only be generated if global option DEBUG is true as it uses crinitDbgInfoPrint().

Variable Documentation

◆ crinitRtimOps

The string/opcode map for all opcodes, initialized in rtimopmap.c.