-
Notifications
You must be signed in to change notification settings - Fork 0
/
getopt.h
46 lines (38 loc) · 1.12 KB
/
getopt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef GETOPT_H
#define GETOPT_H
#include <stddef.h>
#include <tchar.h>
#define ERROR_ILLEGAL_OPT 1
#define ERROR_OPT_REQ_ARG 2
#define ERROR_INVALID_OPT_ARG 3
// Stores of the index next option to be processed in argv
extern int opt_index;
// Sets an one of the ERROR_* codes if an error is encountered
// during option parsing. The caller can use this code to display
// an appropriate message
extern int opt_error;
// Stores a character representing the last parsed option
extern TCHAR opt;
// If an option requires an argument, the parsed argument value
// will be stored here
extern TCHAR *opt_arg;
/*!
* @brief
* Parses the command-line arguments.
*
* @param argc
* Number of command-line arguments passed to the program.
*
* @param argv
* Array of command-line arguments passed to the program.
*
* @param opts
* String containing the options. Options that take an arguments should
* be succeeded by a colon (:).
*
* @returns
* If an option was successfully parsed, the return values is the option
* character; -1 otherwise.
*/
int get_opt(int argc, TCHAR *const argv[], const TCHAR *opts);
#endif // GETOPT_H