Debian Codegraph @

libs/xpdf/xpdf-src/goo/parseargs.h

raw
1 /*
2 * parseargs.h
3 *
4 * Command line argument parser.
5 *
6 * Copyright 1996-2003 Glyph & Cog, LLC
7 */
8
9 #ifndef PARSEARGS_H
10 #define PARSEARGS_H
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 #include "gtypes.h"
17
18 /*
19 * Argument kinds.
20 */
21 typedef enum {
22 argFlag, /* flag (present / not-present) */
23 /* [val: GBool *] */
24 argInt, /* integer arg */
25 /* [val: int *] */
26 argFP, /* floating point arg */
27 /* [val: double *] */
28 argString, /* string arg */
29 /* [val: char *] */
30 /* dummy entries -- these show up in the usage listing only; */
31 /* useful for X args, for example */
32 argFlagDummy,
33 argIntDummy,
34 argFPDummy,
35 argStringDummy
36 } ArgKind;
37
38 /*
39 * Argument descriptor.
40 */
41 typedef struct {
42 const char *arg; /* the command line switch */
43 ArgKind kind; /* kind of arg */
44 void *val; /* place to store value */
45 int size; /* for argString: size of string */
46 const char *usage; /* usage string */
47 } ArgDesc;
48
49 /*
50 * Parse command line. Removes all args which are found in the arg
51 * descriptor list <args>. Stops parsing if "--" is found (and removes
52 * it). Returns gFalse if there was an error.
53 */
54 extern GBool parseArgs(ArgDesc *args, int *argc, char *argv[]);
55
56 /*
57 * Print usage message, based on arg descriptor list.
58 */
59 extern void printUsage(const char *program, const char *otherArgs,
60 ArgDesc *args);
61
62 /*
63 * Check if a string is a valid integer or floating point number.
64 */
65 extern GBool isInt(char *s);
66 extern GBool isFP(char *s);
67
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #endif