Tornado API Reference : Target Server Internal Routines
flagutil - argument parsing utility
flagName( ) - interprets an argument as a "string parameter required" argument.
flagInt( ) - interprets an argument as an "integer parameter required" argument.
flagBool( ) - interprets an argument as a boolean.
This library contains routines which can be used by backends to interpret arguments given to target server's command line.Those routines can be put in the rtn field of the FLAG_DESC structure array given by the backend in response to a bkendFlagsGet () invokation (see API Programmer's Guide: Target Server Back End for details). Each of those routines is given the following two parameters :
int argc, /* number of arguments */ char * argv[], /* table of arguments */The last parameter differs according to the routine called. For instance, the flagInt () routine takes an int address where to return the parsed value.Each routine parses the argv vector of arguments, and can interpret up to argc arguments (argc represents the number of remaining arguments in the vector, and is used for boundary conditions). The first argument (argv[0]) represents the argument which caused the call to the routine. For instance, if the "-foo" argument causes the call to the flagInt () routine, the first argument will be "-foo" itself. The second argument should be an integer value. The flagInt () routine will store the integer value represented by the second argument at the given location. Each routine returns the number of parsed arguments. The flagInt () routine returns 1 if an argument has been evaluated.
#include "flagutil.h"
Those routines are available when linking with the libwpwr shared lib.
flagutil, API Programmer's Guide: Target Server Back End .
flagName( ) - interprets an argument as a "string parameter required" argument.
int flagName ( int argc, /* number of remaining arguments */ char * argv[], /* table of remaining arguments */ char * * pName /* pointer to name to set */ )
This routine sets the given pointer to the address of the argument following the argument causing the call to this routine if this argument exists and does not begins with "-".
Use this routine to evaluate an argument like :
-file /tmp/fooThis routine will store the "/tmp/foo" string address in the pointer pointed to by pName.
1 if a parameter as been correctly evaluated, O otherwise.
flagInt( ) - interprets an argument as an "integer parameter required" argument.
int flagInt ( int argc, /* number of remaining arguments */ char * argv[], /* table of remaining arguments */ int * pInt /* pointer to integer to set */ )
This routine evaluates the argument following the argument causing the call to this routine as an integer. An integer can be signed (with a leading `-'), and can be represented in octal (with a leading `0'), decimal (default), or hexadecimal (with a leading "0x" or "0X"). All the argument string must be evaluated (e.g. a string like "0FF" won't be considered as correct because the `0' indicates an octal representation, and `F' is out of the octal representaion characters array).
Use this routine to evaluate an argument like :
-speed 9600This routine will store the value 9600 in the integer pointed to by pInt.
1 if an argument as been correctly translated, O otherwise.
flagBool( ) - interprets an argument as a boolean.
int flagBool ( int argc, /* number of remaining arguments */ char * argv[], /* table of remaining arguments */ BOOL * pBool /* pointer to boolean to set */ )
This routine sets the given boolean pointer to TRUE.
Use this routine to evaluate an argument like :
-DebugThis routine will set TRUE in the BOOL pointed to by pBool.
0 always (it does not take any arguments).