User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v7.5.x:api:xatmi:ndrx_lcf_xadmin_add.3

ndrx_lcf_xadmin_add

Name

ndrx_lcf_xadmin_add — Register *xadmin(8)* LCF command

Synopsis

#include <lcf.h>

#include <nerror.h>

int ndrx_lcf_xadmin_add(ndrx_lcf_reg_xadmin_t *xcmd);

Link with -lnstd -lpthread -lrt -lm

DESCRIPTION

This function is used to register xadmin(8) Latent Command Framework command. Once function is called, command appears under $ xadmin lcf group of functions. Function registration maps the administrative utility command string to actual command code which is published to configuration shared memory block. All details of the function are encoded in xcmd parameter. This structure also includes version field which is used for forward/backward compatibility. Function registration with xadmin is purely only needed for xadmin user execution. For processes which performs the LCF command, this registration is not required. Instead processes requires ndrx_lcf_func_add(3) callbacks to be registered with. Callback to xadmin can be registered via Enduro/X plugin interface, i.e. use ndrx_plugin_init() entry point. See ex_devguide(guides) for plugin development.

ndrx_lcf_reg_xadmin_t structure is declared as:

typedef struct
{
    int version;
    char cmdstr[NDRX_LCF_ADMINCMD_MAX+1];
    int command;
    char helpstr[NDRX_LCF_ADMINDSCR_MAX+1];
    long dltflags;
    int dfltslot;
} ndrx_lcf_reg_xadmin_t;

Where ndrx_lcf_reg_xadmin_t fields shall be filled in following way:

version - Actual version is present in macros NDRX_LCF_XCMD_VERSION (currently it is 1).

cmdstr - Is command string used in xadmin lcf COMMAND. It must be valid C style identifier. Max command string length is 32+1.

command - This is actual command code. Must be value in range of NDRX_LCF_CMD_MIN_CUST..NDRX_LCF_CMD_MAX_CUST.

helpstr - This is help text appearing in $ xadmin help lcf. Max length of text is 128+1.

dltflags - These are default bitwise flags used by command. These flags also affects the checking of mandatory arguments (-A and/or -B) to be required when command is issued. See value bellow.

dfltslot - Default slot number to which publish this command. May override by xadmin -s argument. Note that slot number must be lower than NDRX_LCFMAX env variable.

DEFAULT FLAGS

NDRX_LCF_FLAG_ALL - Apply command to all binaries in application instance, same as if xadmin lcf COMMAND -a flags would be set command.

NDRX_LCF_FLAG_ARGA - Argument -A is mandatory to have value.

NDRX_LCF_FLAG_ARGB - Argument -B is mandatory to have value.

NDRX_LCF_FLAG_DOSTARTUP - Perform the command at startup of the executable which attaches to existing shared memory segments. This is the same as if xadmin lcf COMMAND -n flag would be set.

NDRX_LCF_FLAG_DOSTARTUPEXP - Perform the command at startup of the executable which attaches to existing shared memory segments, only when command age is less than NDRX_LCFCMDEXP (default is 60 seconds). This is the same as if xadmin lcf COMMAND -e flag would be set.

RETURN VALUE

On success, ndrx_lcf_xadmin_add() returns 0. On error, -1 is returned, with Nerror set to indicate the error.

ERRORS

Note that Nstrerror() returns generic error message plus custom message with debug info from last function call.

NEINVAL xcmd→cmdstr is empty, invalid flags specified. command field is out of range of the range. xcmd is NULL. xcmd→cmdstr is not valid identifier.

NEVERSION Invalid version specified in structure.

NEEXISTS Command with given xcmd→cmdstr is already registered.

NEMALLOC Malloc failed.

THREAD SAFETY

ndrx_lcf_xadmin_add() function is thread safe.

EXAMPLE

See atmitest/test081_lcf/custom_lcf.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd