Disk ARchive  2.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
my_getopt_long.h
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program 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 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 // $Id: my_getopt_long.h,v 1.4 2011/01/09 17:25:58 edrusb Rel $
22 //
23 /*********************************************************************/
24 
28 
29 
30 #ifndef MY_GETOPT_LONG_H
31 #define MY_GETOPT_LONG_H
32 
33 // getopt may be declated in <unistd.h> on systems like FreeBSD.
34 // if you want to use libgnugetopt you need to include <getopt.h>
35 // on this system. Thus a conflict appear because the getopt is
36 // declared twice. To avoid you either have not to include <unistd.h>
37 // or not to include <getopt.h>. But neither the first nor the
38 // second is acceptable, because we need other stuf declared in
39 // <unistd.h> (open() & so on) and stuf declared in <getopt.h>
40 // (like getopt_long which is gnu typical).
41 //
42 // to solve this problem, I have extracted the gnu getopt_long
43 // as declared under Linux in the present file. When getopt is
44 // declared in <unistd.h> it is still possible to include the
45 // current file in place of <getopt.h>, to get getopt_long available
46 //
47 // at linking time, if libgnugetopt is available we use it
48 //
49 // see getopt_decision.hpp
50 
51 # define no_argument 0
52 # define required_argument 1
53 # define optional_argument 2
54 
55 struct option
56 {
57 # if defined __STDC__ && __STDC__
58  const char *name;
59 # else
60  char *name;
61 # endif
62  /* has_arg can't be an enum because some compilers complain about
63  type mismatches in all the code that assumes it is an int. */
64  int has_arg;
65  int *flag;
66  int val;
67 };
68 
69 extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
70  const struct option *__longopts, int *__longind);
71 
72 
73 #endif