diff options
author | Brent Cook <busterb@gmail.com> | 2023-07-07 11:46:21 +0300 |
---|---|---|
committer | Brent Cook <busterb@gmail.com> | 2023-07-07 12:11:20 +0300 |
commit | 7463f87cf1c3b8494a604976a8f818b07747b55e (patch) | |
tree | b650ee1a218d8fdaf5d7794f4b0f2902ca080ce4 /include | |
parent | e06ce19f9531240fa4e754197850184dbcd445fc (diff) | |
download | portable-7463f87cf1c3b8494a604976a8f818b07747b55e.tar.gz portable-7463f87cf1c3b8494a604976a8f818b07747b55e.tar.bz2 portable-7463f87cf1c3b8494a604976a8f818b07747b55e.zip |
add compat getopt implementation, remove patches
This adds a getopt implementation for compatibility where it is not
available, removing a couple of regress patches.
Note, this is a slightly modified copy from OpenBSD libc that doesn't
expose getopt_long, which has dependency conflicts with Windows system
headers and isn't needed anyway.
Diffstat (limited to 'include')
-rw-r--r-- | include/compat/getopt.h | 50 | ||||
-rw-r--r-- | include/compat/unistd.h | 4 |
2 files changed, 54 insertions, 0 deletions
diff --git a/include/compat/getopt.h b/include/compat/getopt.h new file mode 100644 index 0000000..8cc3207 --- /dev/null +++ b/include/compat/getopt.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /* $OpenBSD: getopt.h,v 1.3 2013/11/22 21:32:49 millert Exp $ */ | ||
2 | /* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * This code is derived from software contributed to The NetBSD Foundation | ||
9 | * by Dieter Baron and Thomas Klausner. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer. | ||
16 | * 2. Redistributions in binary form must reproduce the above copyright | ||
17 | * notice, this list of conditions and the following disclaimer in the | ||
18 | * documentation and/or other materials provided with the distribution. | ||
19 | * | ||
20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | ||
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | ||
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
30 | * POSSIBILITY OF SUCH DAMAGE. | ||
31 | */ | ||
32 | |||
33 | #ifdef HAVE_GETOPT | ||
34 | |||
35 | #include_next <getopt.h> | ||
36 | |||
37 | #else | ||
38 | |||
39 | #ifndef _GETOPT_DEFINED_ | ||
40 | #define _GETOPT_DEFINED_ | ||
41 | int getopt(int, char * const *, const char *); | ||
42 | |||
43 | extern char *optarg; /* getopt(3) external variables */ | ||
44 | extern int opterr; | ||
45 | extern int optind; | ||
46 | extern int optopt; | ||
47 | extern int optreset; | ||
48 | #endif | ||
49 | |||
50 | #endif /* HAVE_GETOPT */ | ||
diff --git a/include/compat/unistd.h b/include/compat/unistd.h index 5e6ab1d..2583a6e 100644 --- a/include/compat/unistd.h +++ b/include/compat/unistd.h | |||
@@ -64,6 +64,10 @@ int getentropy(void *buf, size_t buflen); | |||
64 | #endif | 64 | #endif |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #ifndef HAVE_GETOPT | ||
68 | #include <getopt.h> | ||
69 | #endif | ||
70 | |||
67 | #ifndef HAVE_GETPAGESIZE | 71 | #ifndef HAVE_GETPAGESIZE |
68 | int getpagesize(void); | 72 | int getpagesize(void); |
69 | #endif | 73 | #endif |