29
25
* ***** END GPL LICENSE BLOCK *****
28
#ifndef __BLI_ARGS_H__
29
#define __BLI_ARGS_H__
33
* \brief A general argument parsing module.
36
37
typedef struct bArgs bArgs;
38
39
/* returns the number of extra arguments consumed by the function. 0 is normal value, -1 stops parsing arguments, other negative indicates skip */
39
typedef int (*BA_ArgCallback)(int argc, char **argv, void *data);
40
typedef int (*BA_ArgCallback)(int argc, const char **argv, void *data);
41
struct bArgs *BLI_argsInit(int argc, char **argv);
42
struct bArgs *BLI_argsInit(int argc, const char **argv);
42
43
void BLI_argsFree(struct bArgs *ba);
44
45
/* pass starts at 1, -1 means valid all the time
45
46
* short_arg or long_arg can be null to specify no short or long versions
47
void BLI_argsAdd(struct bArgs *ba, int pass, char *short_arg, char *long_arg, char *doc, BA_ArgCallback cb, void *data);
48
void BLI_argsAdd(struct bArgs *ba, int pass, const char *short_arg, const char *long_arg, const char *doc, BA_ArgCallback cb, void *data);
48
49
/* short_case and long_case specify if those arguments are case specific */
49
void BLI_argsAddCase(struct bArgs *ba, int pass, char *short_arg, int short_case, char *long_arg, int long_case, char *doc, BA_ArgCallback cb, void *data);
50
void BLI_argsAddCase(struct bArgs *ba, int pass, const char *short_arg, int short_case, const char *long_arg, int long_case, const char *doc, BA_ArgCallback cb, void *data);
51
52
void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *data);
53
void BLI_argsPrintArgDoc(struct bArgs *ba, char *arg);
54
void BLI_argsPrintArgDoc(struct bArgs *ba, const char *arg);
54
55
void BLI_argsPrintOtherDoc(struct bArgs *ba);
56
57
void BLI_argsPrint(struct bArgs *ba);
57
char **BLI_argsArgv(struct bArgs *ba);
58
const char **BLI_argsArgv(struct bArgs *ba);