#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | parseoptsDefinition |
Structure for defining possible command line options. More... | |
struct | parseoptsOptionStruct |
Structure for command line options. More... | |
Defines | |
#define | OPTION_CHANNEL 129 |
#define | OPTION_ERR_ALLOC -2 |
#define | OPTION_ERR_MISSING_ARGUMENT -5 |
#define | OPTION_ERR_NO_ARGS -1 |
#define | OPTION_ERR_NOT_APPLICABLE -4 |
#define | OPTION_ERR_UNKNOWN_OPTION -3 |
#define | OPTION_FBS 12 |
#define | OPTION_FILES 128 |
#define | OPTION_FORCE 9 |
#define | OPTION_FTP 10 |
#define | OPTION_HAS_ARGS 1 |
#define | OPTION_HELP 3 |
#define | OPTION_IN_DIR 132 |
#define | OPTION_NO_ARGS 0 |
#define | OPTION_OUT_DIR 131 |
#define | OPTION_PIN 127 |
#define | OPTION_PULL 6 |
#define | OPTION_PULL_ALL 8 |
#define | OPTION_PULL_STD 7 |
#define | OPTION_PUSH 5 |
#define | OPTION_RFCOMM_FILE 130 |
#define | OPTION_SCAN 4 |
#define | OPTION_SYNC 11 |
#define | OPTION_VERBOSE 1 |
#define | OPTION_XML 2 |
#define | PARSEOPTS_RETURN_ERROR -1 |
#define | PARSEOPTS_RETURN_INAPPLICABLE -2 |
#define | PARSEOPTS_RETURN_MISSING_ARGUMENT -4 |
#define | PARSEOPTS_RETURN_SUCCESS 1 |
#define | PARSEOPTS_RETURN_UNKNOWN -3 |
#define | TOOL_ALL TOOL_SCANNER |TOOL_SDPTOOL | TOOL_OPPTOOL | TOOL_RFCOMM |
#define | TOOL_NONE 0x00 |
#define | TOOL_OPPTOOL 0x04 |
#define | TOOL_RFCOMM 0x08 |
#define | TOOL_SCANNER 0x01 |
#define | TOOL_SDPTOOL 0x02 |
Functions | |
void | freeOpts (struct parseoptsOptionStruct *pOpts) |
Releases memory allocated by a call to parseOpts. | |
int | getopts (int argc, char **argv, char **pArgs, int tool) |
Get next command line option. | |
char * | optionSetValue (const char *pNewValue, char *pChangeValue) |
Helper function for setting char array values dynamically. | |
int | parseOpts (int argc, char **argv, struct parseoptsOptionStruct *pOpts, int tool) |
Parse command line options. |
#define OPTION_CHANNEL 129 |
Channel option, --channel
Definition at line 123 of file parseOpts.h.
#define OPTION_ERR_ALLOC -2 |
Indicates an error in allocating memory. Probably fatal, should exit
Definition at line 103 of file parseOpts.h.
#define OPTION_ERR_MISSING_ARGUMENT -5 |
Indicates that an option that should have an argument did not have one.
Definition at line 106 of file parseOpts.h.
#define OPTION_ERR_NO_ARGS -1 |
Indicates no more options to parse, ie. end of options or no options given
Definition at line 102 of file parseOpts.h.
#define OPTION_ERR_NOT_APPLICABLE -4 |
Indicates option not applicable to this tool
Definition at line 105 of file parseOpts.h.
#define OPTION_ERR_UNKNOWN_OPTION -3 |
Indicates an unknown option on the command line
Definition at line 104 of file parseOpts.h.
#define OPTION_FBS 12 |
File Browsing service option, --fbs
Definition at line 120 of file parseOpts.h.
#define OPTION_FILES 128 |
File list option, --files
Definition at line 122 of file parseOpts.h.
#define OPTION_FORCE 9 |
Force option, --force
Definition at line 117 of file parseOpts.h.
#define OPTION_FTP 10 |
File Transfer Profile option, --ftp
Definition at line 118 of file parseOpts.h.
#define OPTION_HAS_ARGS 1 |
Boolean value indicating option must have an argument
Definition at line 98 of file parseOpts.h.
#define OPTION_HELP 3 |
Help option, --help
Definition at line 111 of file parseOpts.h.
#define OPTION_IN_DIR 132 |
Input dir option, --in-dir
Definition at line 126 of file parseOpts.h.
#define OPTION_NO_ARGS 0 |
Boolean value indicating option does not have an argument
Definition at line 99 of file parseOpts.h.
#define OPTION_OUT_DIR 131 |
Output dir option, --out-dir
Definition at line 125 of file parseOpts.h.
#define OPTION_PIN 127 |
PIN option, --pin
Definition at line 121 of file parseOpts.h.
#define OPTION_PULL 6 |
Pull option, --pull
Definition at line 114 of file parseOpts.h.
#define OPTION_PULL_ALL 8 |
Pull all files option, --pull-all
Definition at line 116 of file parseOpts.h.
#define OPTION_PULL_STD 7 |
Pull standard files option, --pull-std-files
Definition at line 115 of file parseOpts.h.
#define OPTION_PUSH 5 |
Push option, --push
Definition at line 113 of file parseOpts.h.
#define OPTION_RFCOMM_FILE 130 |
RFCOMM input file option, --file
Definition at line 124 of file parseOpts.h.
#define OPTION_SCAN 4 |
Scan option, --scan
Definition at line 112 of file parseOpts.h.
#define OPTION_SYNC 11 |
SyncML profile option, --sync
Definition at line 119 of file parseOpts.h.
#define OPTION_VERBOSE 1 |
Verbose option, --verbose
Definition at line 109 of file parseOpts.h.
#define OPTION_XML 2 |
XML option, --xml
Definition at line 110 of file parseOpts.h.
#define PARSEOPTS_RETURN_ERROR -1 |
Indicates memory allocation problems
Definition at line 138 of file parseOpts.h.
#define PARSEOPTS_RETURN_INAPPLICABLE -2 |
Indicates an inapplicable option was present
Definition at line 139 of file parseOpts.h.
#define PARSEOPTS_RETURN_MISSING_ARGUMENT -4 |
Indicates a missing argument when an option must have one
Definition at line 141 of file parseOpts.h.
#define PARSEOPTS_RETURN_SUCCESS 1 |
Indicates success, no inapplicable or unknown options or memory allocation problems
Definition at line 137 of file parseOpts.h.
#define PARSEOPTS_RETURN_UNKNOWN -3 |
Indicates an unknown option was present
Definition at line 140 of file parseOpts.h.
#define TOOL_ALL TOOL_SCANNER |TOOL_SDPTOOL | TOOL_OPPTOOL | TOOL_RFCOMM |
Constant bitmask indicating all the tools. Used with parseOpts()
Definition at line 134 of file parseOpts.h.
#define TOOL_NONE 0x00 |
Constant bitmask indicating no tool. Used with parseOpts(), included for the sake of completeness
Definition at line 129 of file parseOpts.h.
#define TOOL_OPPTOOL 0x04 |
Constant bitmask indicating the opptool tool. Used with parseOpts()
Definition at line 132 of file parseOpts.h.
#define TOOL_RFCOMM 0x08 |
Constant bitmask indicating the rfcomm tool. Used with parseOpts()
Definition at line 133 of file parseOpts.h.
#define TOOL_SCANNER 0x01 |
Constant bitmask indicating the scanner tool. Used with parseOpts()
Definition at line 130 of file parseOpts.h.
#define TOOL_SDPTOOL 0x02 |
Constant bitmask indicating the sdptool tool. Used with parseOpts()
Definition at line 131 of file parseOpts.h.
void freeOpts | ( | struct parseoptsOptionStruct * | pOpts | ) |
Releases memory allocated by a call to parseOpts.
pOpts | Pointer to struct where options are stored. |
int getopts | ( | int | argc, | |
char ** | argv, | |||
char ** | pArgs, | |||
int | tool | |||
) |
Get next command line option.
Parses the command line and returns the next option, if any, along with possible arguments.
argc | - Number of command line options, pass from main | |
**argv | - Array of command line options, pass from main | |
**pArgs | - Pointer to possible option argument | |
tool | - Tool identifier, see TOOL_* defines in parseOpts.h |
OPTION_ERR_NO_ARGS - No arguments to parse.
OPTION_ERR_NOT_APPLICABLE - Option not applicable to this tool.
OPTION_ERR_MISSING_ARGUMENT - Option that should have an argument did not have one.
[Positive #] - The number in the struct for the matched arg.
char* optionSetValue | ( | const char * | pNewValue, | |
char * | pChangeValue | |||
) |
Helper function for setting char array values dynamically.
pNewValue | - Pointer to new value of array, null-terminated string | |
pChangeValue | - Pointer to array to change |
int parseOpts | ( | int | argc, | |
char ** | argv, | |||
struct parseoptsOptionStruct * | pOpts, | |||
int | tool | |||
) |
Parse command line options.
Used to easily parse command line options. Returns the command line options in an optStruct.
argc | - Number of command line options, pass from main | |
argv | - Array of command line options, pass from main | |
pOpts | - Pointer to struct where options will be stored, allocate and initialize before the call. | |
tool | - Tool identifier, see TOOL_* defines in parseOpts.h |
PARSEOPTS_RETURN_SUCCESS - Indicates success, no inapplicable or unknown options or memory allocation problems.
PARSEOPTS_RETURN_INAPPLICABLE - Indicates an inapplicable option was present.
PARSEOPTS_RETURN_UNKNOWN - Indicates an unknown option was present.
PARSEOPTS_RETURN_MISSING_ARGUMENT - Indicates a missing argument when an option must have one.