]> git.mxchange.org Git - flightgear.git/blob - Main/fg_getopt.h
7e50d1cc16d92962cd687181a94ec96cc4cc49a3
[flightgear.git] / Main / fg_getopt.h
1 /****************************************************************************
2 *
3 *               Copyright (C) 1991-1997 SciTech Software, Inc.
4 *                            All rights reserved.
5 *
6 *  ======================================================================
7 *       This library is free software; you can use it and/or
8 *       modify it under the terms of the SciTech MGL Software License.
9 *
10 *       This library is distributed in the hope that it will be useful,
11 *       but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *       SciTech MGL Software License for more details.
14 *  ======================================================================
15 *
16 * Filename:     $Workfile:   getopt.h  $
17 * Version:      $Revision$
18 *
19 * Language:     ANSI C
20 * Environment:  any
21 *
22 * Description:  Header file for command line parsing module. This module
23 *               contains code to parse the command line, extracting options
24 *               and parameters in standard System V style.
25 *
26 * $Date$ $Author$
27 *
28 * $Id$
29 * (Log is kept at end of this file)
30 *
31 ****************************************************************************/
32
33 #ifndef __GETOPT_H
34 #define __GETOPT_H
35
36 //#ifndef __DEBUG_H
37 //#include "debug.h"
38 //#endif
39
40 /*---------------------------- Typedef's etc -----------------------------*/
41
42 #define ALLDONE     -1
43 #define PARAMETER   -2
44 #define INVALID     -3
45 #define HELP        -4
46
47 #define MAXARG      80
48
49 /* Option type sepecifiers */
50
51 #define OPT_INTEGER     'd'
52 #define OPT_HEX         'h'
53 #define OPT_OCTAL       'o'
54 #define OPT_UNSIGNED    'u'
55 #define OPT_LINTEGER    'D'
56 #define OPT_LHEX        'H'
57 #define OPT_LOCTAL      'O'
58 #define OPT_LUNSIGNED   'U'
59 #define OPT_FLOAT       'f'
60 #define OPT_DOUBLE      'F'
61 #define OPT_LDOUBLE     'L'
62 #define OPT_STRING      's'
63 #define OPT_SWITCH      '!'
64
65 // I need to generate a typedefs file for this.
66 //
67 #ifndef uchar
68 typedef unsigned char uchar;
69 #endif
70 #ifndef uint
71 typedef unsigned int uint;
72 #endif
73
74 #ifndef ulong
75 typedef unsigned long ulong;
76 #endif
77
78 #ifndef bool
79 #ifndef BOOL
80 typedef int BOOL;
81 #endif
82 typedef BOOL bool;
83 #endif
84
85 #ifndef true
86 #ifndef TRUE
87 #define TRUE 1
88 #define FALSE 0
89 #endif
90 #define true TRUE
91 #define false FALSE
92 #endif
93
94 typedef struct {
95     uchar   opt;                /* The letter to describe the option    */
96     uchar   type;               /* Type descriptor for the option       */
97     void    *arg;               /* Place to store the argument          */
98     char    *desc;              /* Description for this option          */
99     } Option;
100
101 #define NUM_OPT(a)  sizeof(a) / sizeof(Option)
102
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106
107 /*--------------------------- Global variables ---------------------------*/
108
109 extern  int     nextargv;
110 extern  char    *nextchar;
111
112 /*------------------------- Function Prototypes --------------------------*/
113
114 // extern int getopt(int argc,char **argv,char *format,char **argument);
115
116 extern int getargs(int argc, char *argv[],int num_opt, Option ** optarr,
117                    int (*do_param)(char *param,int num));
118
119 extern void print_desc(int num_opt, Option **optarr);  // Not original code
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125 #endif
126
127
128 /* $Log$
129 /* Revision 1.1  1998/02/13 00:23:39  curt
130 /* Initial revision.
131 /*
132  */