Tornado API Reference : Target Server Internal Routines

flagutil

NAME

flagutil - argument parsing utility

ROUTINES

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.

DESCRIPTION

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

#include "flagutil.h"

LIBRARY

Those routines are available when linking with the libwpwr shared lib.

SEE ALSO

flagutil, API Programmer's Guide: Target Server Back End .


Target Server Internal Routines : Routines

flagName( )

NAME

flagName( ) - interprets an argument as a "string parameter required" argument.

SYNOPSIS

int flagName
    (
    int      argc,   /* number of remaining arguments */
    char *   argv[], /* table of remaining arguments */
    char * * pName   /* pointer to name to set */
    )

DESCRIPTION

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/foo
This routine will store the "/tmp/foo" string address in the pointer pointed to by pName.

RETURNS

1 if a parameter as been correctly evaluated, O otherwise.

SEE ALSO

flagutil


Target Server Internal Routines : Routines

flagInt( )

NAME

flagInt( ) - interprets an argument as an "integer parameter required" argument.

SYNOPSIS

int flagInt
    (
    int    argc,   /* number of remaining arguments */
    char * argv[], /* table of remaining arguments */
    int *  pInt    /* pointer to integer to set */
    )

DESCRIPTION

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 9600
This routine will store the value 9600 in the integer pointed to by pInt.

RETURNS

1 if an argument as been correctly translated, O otherwise.

SEE ALSO

flagutil


Target Server Internal Routines : Routines

flagBool( )

NAME

flagBool( ) - interprets an argument as a boolean.

SYNOPSIS

int flagBool
    (
    int    argc,   /* number of remaining arguments */
    char * argv[], /* table of remaining arguments */
    BOOL * pBool   /* pointer to boolean to set */
    )

DESCRIPTION

This routine sets the given boolean pointer to TRUE.

Use this routine to evaluate an argument like :

-Debug 
This routine will set TRUE in the BOOL pointed to by pBool.

RETURNS

0 always (it does not take any arguments).

SEE ALSO

flagutil