83
83
#define RTGETOPT_REQ_MACADDR 14
84
84
/** The value must be a valid UUID. */
85
85
#define RTGETOPT_REQ_UUID 15
86
/** The value must be a string with value as "on" or "off". */
87
#define RTGETOPT_REQ_BOOL_ONOFF 16
86
88
/** The mask of the valid required types. */
87
#define RTGETOPT_REQ_MASK 15
89
#define RTGETOPT_REQ_MASK 31
88
90
/** Treat the value as hexadecimal - only applicable with the RTGETOPT_REQ_*INT*. */
89
91
#define RTGETOPT_FLAG_HEX RT_BIT(16)
90
92
/** Treat the value as octal - only applicable with the RTGETOPT_REQ_*INT*. */
91
93
#define RTGETOPT_FLAG_OCT RT_BIT(17)
92
94
/** Treat the value as decimal - only applicable with the RTGETOPT_REQ_*INT*. */
93
95
#define RTGETOPT_FLAG_DEC RT_BIT(18)
96
/** The index value is attached to the argument - only valid for long arguments. */
97
#define RTGETOPT_FLAG_INDEX RT_BIT(19)
94
98
/** Mask of valid bits - for validation. */
95
#define RTGETOPT_VALID_MASK ( RTGETOPT_REQ_MASK | RTGETOPT_FLAG_HEX | RTGETOPT_FLAG_OCT | RTGETOPT_FLAG_DEC )
99
#define RTGETOPT_VALID_MASK ( RTGETOPT_REQ_MASK \
100
| RTGETOPT_FLAG_HEX \
101
| RTGETOPT_FLAG_OCT \
102
| RTGETOPT_FLAG_DEC \
103
| RTGETOPT_FLAG_INDEX)
192
202
const char *pszNextShort;
193
203
/** The option definition which matched. NULL otherwise. */
194
204
PCRTGETOPTDEF pDef;
205
/** The index of an index option, otherwise UINT64_MAX. */
195
207
/* More members will be added later for dealing with initial
196
208
call, optional sorting, '--' and so on. */
323
335
RTDECL(int) RTGetOpt(PRTGETOPTSTATE pState, PRTGETOPTUNION pValueUnion);
338
* Fetch an additional value.
340
* This is used for special cases where an option have more than one value.
343
* @returns VINF_SUCCESS on success.
344
* @returns IPRT error status on parse error.
345
* @returns VERR_INVALID_PARAMETER if the flags are wrong.
346
* @returns VERR_GETOPT_UNKNOWN_OPTION when pState->pDef is null.
347
* @returns VERR_GETOPT_REQUIRED_ARGUMENT_MISSING if there are no more
348
* available arguments. pValueUnion->pDef is NULL.
349
* @returns VERR_GETOPT_INVALID_ARGUMENT_FORMAT and pValueUnion->pDef if
350
* value conversion failed.
352
* @param pState The state previously initialized with RTGetOptInit.
353
* @param pValueUnion Union with value; in the event of an error, psz member
354
* points to erroneous parameter; otherwise, for options
355
* that require an argument, this contains the value of
356
* that argument, depending on the type that is required.
357
* @param fFlags The flags.
359
RTDECL(int) RTGetOptFetchValue(PRTGETOPTSTATE pState, PRTGETOPTUNION pValueUnion, uint32_t fFlags);
362
* Print error messages for a RTGetOpt default case.
366
* @returns Suitable exit code.
368
* @param ch The RTGetOpt return value.
369
* @param pValueUnion The value union returned by RTGetOpt.
371
RTDECL(int) RTGetOptPrintError(int ch, PCRTGETOPTUNION pValueUnion);