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 Albert Astals Cid <aacid@kde.org>
17 
18  To see a description of the changes please see the Changelog file that
19  came with your tarball or type make ChangeLog if you are building from git
20 
21 ========================================================================*/
22 
23 #ifndef PARSEARGS_H
24 #define PARSEARGS_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include "goo/gtypes.h"
31 
32 /*
33  * Argument kinds.
34  */
35 typedef enum {
36   argFlag,			/* flag (present / not-present) */
37 				/*   [val: GBool *]             */
38   argInt,			/* integer arg    */
39 				/*   [val: int *] */
40   argFP,			/* floating point arg */
41 				/*   [val: double *]  */
42   argString,			/* string arg      */
43 				/*   [val: char *] */
44   /* dummy entries -- these show up in the usage listing only; */
45   /* useful for X args, for example                            */
46   argFlagDummy,
47   argIntDummy,
48   argFPDummy,
49   argStringDummy
50 } ArgKind;
51 
52 /*
53  * Argument descriptor.
54  */
55 typedef struct {
56   char *arg;			/* the command line switch */
57   ArgKind kind;			/* kind of arg */
58   void *val;			/* place to store value */
59   int size;			/* for argString: size of string */
60   char *usage;			/* usage string */
61 } ArgDesc;
62 
63 /*
64  * Parse command line.  Removes all args which are found in the arg
65  * descriptor list <args>.  Stops parsing if "--" is found (and removes
66  * it).  Returns gFalse if there was an error.
67  */
68 extern GBool parseArgs(const ArgDesc *args, int *argc, char *argv[]);
69 
70 /*
71  * Print usage message, based on arg descriptor list.
72  */
73 extern void printUsage(char *program, char *otherArgs, const ArgDesc *args);
74 
75 /*
76  * Check if a string is a valid integer or floating point number.
77  */
78 extern GBool isInt(char *s);
79 extern GBool isFP(char *s);
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif
86