arg_parse.c File Reference

Command-line arguments parsing functions. More...

#include <arg_parse.h>
#include <errno.h>
#include <str.h>

Go to the source code of this file.

Functions

int arg_parse_int (int argc, char *argv[], int *index, int *value, int offset)
 Parse the next argument as an integer.
int arg_parse_name_int (int argc, char *argv[], int *index, int *value, int offset, arg_parser parser)
 Parse the next named argument as an integral number.
int arg_parse_short_long (const char *arg, const char *ashort, const char *along)
int arg_parse_string (int argc, char **argv, int *index, char **value, int offset)
 Parse the next argument as a character string.


Detailed Description

Command-line arguments parsing functions.

Definition in file arg_parse.c.


Function Documentation

int arg_parse_int ( int  argc,
char *  argv[],
int *  index,
int *  value,
int  offset 
)

Parse the next argument as an integer.

The actual argument is pointed by the index. Parse the offseted argument value if the offset is set or the next one if not.

Parameters:
[in] argc The total number of arguments.
[in] argv The arguments.
[in,out] index The actual argument index. The index is incremented by the number of processed arguments.
[out] value The parsed argument value.
[in] offset The value offset in the actual argument. If not set, the next argument is parsed instead.
Returns:
EOK on success.

ENOENT if the argument is missing.

EINVAL if the argument is in wrong format.

Definition at line 67 of file arg_parse.c.

int arg_parse_name_int ( int  argc,
char *  argv[],
int *  index,
int *  value,
int  offset,
arg_parser  parser 
)

Parse the next named argument as an integral number.

The actual argument is pointed by the index. Parse the offseted actual argument if the offset is set or the next one if not. Translate the argument using the parse_value function. Increment the actual index by the number of processed arguments.

Parameters:
[in] argc The total number of arguments.
[in] argv The arguments.
[in,out] index The actual argument index. The index is incremented by the number of processed arguments.
[out] value The parsed argument value.
[in] offset The value offset in the actual argument. If not set, the next argument is parsed instead.
[in] parse_value The translation function to parse the named value.
Returns:
EOK on success.

ENOENT if the argument is missing.

EINVAL if the argument name has not been found.

Definition at line 107 of file arg_parse.c.


Generated on Thu Jun 2 07:45:52 2011 for HelenOS/USB by  doxygen 1.4.7