| 313 |
dpurdie |
1 |
#ifndef GETOPT_H_INCLUDED
|
|
|
2 |
#define GETOPT_H_INCLUDED
|
|
|
3 |
/* -*- c: tabs: 4 -*- ******************************************************
|
|
|
4 |
* Module name : getopt.h
|
|
|
5 |
* Module type : Core Service public header
|
|
|
6 |
* Compiler(s) : ANSI C
|
|
|
7 |
* Environment(s): n/a
|
|
|
8 |
*
|
|
|
9 |
* Description:
|
|
|
10 |
*
|
|
|
11 |
Option parsing (with long name support)
|
|
|
12 |
*
|
|
|
13 |
* Version Who Date Description
|
|
|
14 |
1.0 APY 07/05/98 Taken from prt source
|
|
|
15 |
*
|
|
|
16 |
* $Name: $
|
|
|
17 |
* $Source: /cvsroot/device/DEVL/UTILS/CMDFILE/getopt.h,v $
|
|
|
18 |
* $Revision: 1.1 $ $Date: 2002/08/02 06:49:27 $ $State: Exp $
|
|
|
19 |
* $Author: adamy $ $Locker: $
|
|
|
20 |
*............................................................................*/
|
|
|
21 |
|
|
|
22 |
#include "cdefs.h"
|
|
|
23 |
|
|
|
24 |
/*
|
|
|
25 |
* Global Variables
|
|
|
26 |
* ----------------
|
|
|
27 |
*/
|
|
|
28 |
extern int opterr; /* if error message should be printed */
|
|
|
29 |
extern int optind; /* index into parent argv vector */
|
|
|
30 |
extern int optlidx; /* index into long argument list */
|
|
|
31 |
extern int optopt; /* character checked for validity */
|
|
|
32 |
extern char *optarg; /* argument associated with option */
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
* Function Prototypes
|
|
|
36 |
* -------------------
|
|
|
37 |
*/
|
|
|
38 |
#define no_argument 0
|
|
|
39 |
#define required_argument 1
|
|
|
40 |
#define optional_argument 2
|
|
|
41 |
|
|
|
42 |
struct option
|
|
|
43 |
{
|
|
|
44 |
char *name; /* long argument name */
|
|
|
45 |
int has_arg; /* 0=no arg, 1=arg required, 2=optional arg */
|
|
|
46 |
int *flag; /* var with 'val' value upon detection */
|
|
|
47 |
int val; /* value return on detection */
|
|
|
48 |
};
|
|
|
49 |
|
|
|
50 |
__BEGIN_DECLS
|
|
|
51 |
extern int getopt __P((int nargc, char *const *nargv,
|
|
|
52 |
const char *ostr));
|
|
|
53 |
extern int getoptl __P((int nargc, char *const *nargv,
|
|
|
54 |
const char *ostr, const struct option *lopt,
|
|
|
55 |
int long_only));
|
|
|
56 |
extern int getopt_long __P((int nargc, char *const *nargv,
|
|
|
57 |
const char *ostr, const struct option *lopts,
|
|
|
58 |
int *longind));
|
|
|
59 |
extern int getopt_long_only __P((int nargc, char *const *nargv,
|
|
|
60 |
const char *ostr, const struct option *lopts,
|
|
|
61 |
int *longind));
|
|
|
62 |
__END_DECLS
|
|
|
63 |
|
|
|
64 |
#endif /* GETOPT_H_INCLUDED */
|
|
|
65 |
|
|
|
66 |
|