| Disk ARchive 2.6.12 Full featured and portable backup and archiving tool

my_getopt_long.h
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26
27 #ifndef MY_GETOPT_LONG_H
28 #define MY_GETOPT_LONG_H
29
30 // getopt may be declated in <unistd.h> on systems like FreeBSD.
31 // if you want to use libgnugetopt you need to include <getopt.h>
32 // on this system. Thus a conflict appear because the getopt is
33 // declared twice. To avoid you either have not to include <unistd.h>
34 // or not to include <getopt.h>. But neither the first nor the
35 // second is acceptable, because we need other stuf declared in
36 // <unistd.h> (open() & so on) and stuf declared in <getopt.h>
37 // (like getopt_long which is gnu typical).
38 //
39 // to solve this problem, I have extracted the gnu getopt_long
40 // as declared under Linux in the present file. When getopt is
41 // declared in <unistd.h> it is still possible to include the
42 // current file in place of <getopt.h>, to get getopt_long available
43 //
44 // at linking time, if libgnugetopt is available we use it
45 //
46 // see getopt_decision.hpp
47
48 # define no_argument 0
49 # define required_argument 1
50 # define optional_argument 2
51
52 struct option
53 {
54 # if defined __STDC__ && __STDC__
55 const char *name;
56 # else
57 char *name;
58 # endif
59 /* has_arg can't be an enum because some compilers complain about
60 type mismatches in all the code that assumes it is an int. */
61 int has_arg;
62 int *flag;
63 int val;
64 };
65
66 extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
67 const struct option *__longopts, int *__longind);
68
69
70 #endif