-
Notifications
You must be signed in to change notification settings - Fork 5
/
getarg.h
48 lines (45 loc) · 1.31 KB
/
getarg.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
47
48
/**
* # getarg.h:
* Replacement for the POSIX `getopt()` function for processing
* command-line options. I use it for compiling programs that require command-
* line arguments under Windows, but my goal is to have it portable to use
* in programs compiled on other platforms.
*
* Although I've consulted the relavant `getopt()` manual pages, this
* implementation is entirely my own.
*
* Use it as you would use `getopt()`, but replace all the "opt" prefixes
* with "arg"
*
* ### License
*
* Author: Werner Stoop
* This is free and unencumbered software released into the public domain.
* See http://unlicense.org/ for more details.
*
* ## API
*/
#ifndef GETARG_H
#define GETARG_H
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
/**
* ### Variables
*
* * `argind` - Replaces `getopt()`'s `optind`
* * `argopt` - Replaces `getopt()`'s `optopt`
* * `argarg` - Replaces `getopt()`'s `optarg`
*/
extern char *argarg;
extern int argind, argopt;
/**
* ### Functions
* #### `char getarg(int argc, char * const argv[], const char *opts)`
* Use this as you would use `getopt()`
*/
char getarg(int argc, char * const argv[], const char *opts);
#if defined(__cplusplus) || defined(c_plusplus)
} /* extern "C" */
#endif
#endif /* GETARG_H */