-
Notifications
You must be signed in to change notification settings - Fork 0
/
popt.h
70 lines (56 loc) · 1.8 KB
/
popt.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (C) 2015 The Android Open Source Project
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef ANDROID_POPT_H
#define ANDROID_POPT_H
/*
* popt has been deprecated for some time, and is replaced by GNOME's glib
* option parser. Instead of pulling in either of those dependencies, this
* stub implements just enough of popt to get things working.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#define POPT_ARG_NONE 0U
#define POPT_ARG_STRING 1U
#define POPT_ARG_INT 2U
#define POPT_AUTOHELP
#pragma pack(push)
#pragma pack(0)
struct poptOption {
const char *longName;
char shortName;
unsigned int argInfo;
void *arg;
int val;
const char *descrip;
const char *argDescrip;
};
struct _poptContext {
int argc;
const char **argv;
const struct poptOption *options;
struct option *long_options;
const char *otherHelp;
};
typedef struct _poptContext *poptContext;
#pragma pack(pop)
poptContext poptGetContext(const char *name, int argc, const char **argv,
const struct poptOption *options, unsigned int flags);
poptContext poptFreeContext(poptContext con);
void poptResetContext(poptContext con);
void poptSetOtherOptionHelp(poptContext con, const char *text);
void poptPrintUsage(poptContext con, FILE *fp, int flags);
int poptGetNextOpt(poptContext con);
const char *poptGetArg(poptContext con);
#endif