1 /*
2  * parseargs.h
3  *
4  * Command line argument parser.
5  *
6  * Copyright 1996-2003 Glyph & Cog, LLC
7  */
8 
9 /*========================================================================
10 
11  Modified under the Poppler project - http://poppler.freedesktop.org
12 
13  All changes made under the Poppler project to this file are licensed
14  under GPL version 2 or later
15 
16  Copyright (C) 2008, 2018 Albert Astals Cid <aacid@kde.org>
17  Copyright (C) 2011 Adrian Johnson <ajohnson@redneon.com>
18 
19  To see a description of the changes please see the Changelog file that
20  came with your tarball or type make ChangeLog if you are building from git
21 
22 ========================================================================*/
23 
24 #ifndef PARSEARGS_H
25 #define PARSEARGS_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /*
32  * Argument kinds.
33  */
34 typedef enum
35 {
36     argFlag, /* flag (present / not-present) */
37     /*   [val: bool *]             */
38     argInt, /* integer arg    */
39     /*   [val: int *] */
40     argFP, /* floating point arg */
41     /*   [val: double *]  */
42     argString, /* string arg      */
43     /*   [val: char *] */
44     argGooString, /* string arg      */
45     /*   [val: GooString *] */
46     /* dummy entries -- these show up in the usage listing only; */
47     /* useful for X args, for example                            */
48     argFlagDummy,
49     argIntDummy,
50     argFPDummy,
51     argStringDummy
52 } ArgKind;
53 
54 /*
55  * Argument descriptor.
56  */
57 typedef struct
58 {
59     const char *arg; /* the command line switch */
60     ArgKind kind; /* kind of arg */
61     void *val; /* place to store value */
62     int size; /* for argString: size of string */
63     const char *usage; /* usage string */
64 } ArgDesc;
65 
66 /*
67  * Parse command line.  Removes all args which are found in the arg
68  * descriptor list <args>.  Stops parsing if "--" is found (and removes
69  * it).  Returns false if there was an error.
70  */
71 extern bool parseArgs(const ArgDesc *args, int *argc, char *argv[]);
72 
73 /*
74  * Print usage message, based on arg descriptor list.
75  */
76 extern void printUsage(const char *program, const char *otherArgs, const ArgDesc *args);
77 
78 /*
79  * Check if a string is a valid integer or floating point number.
80  */
81 extern bool isInt(const char *s);
82 extern bool isFP(const char *s);
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif
89