From abbad00edd7f5f3d33ae77a9d5ac338e5bea5fb3 Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Tue, 12 Feb 2008 12:03:58 +0000 Subject: Import Gnulib floorf and base64 and removed our old base64 library. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1926 f882894a-f735-0410-b71e-b25c423dba1c --- gl/Makefile.am | 81 ++++++- gl/base64.c | 425 ++++++++++++++++++++++++++++++++++ gl/base64.h | 45 ++++ gl/charset.alias | 5 + gl/configmake.h | 25 ++ gl/floor.c | 93 ++++++++ gl/floorf.c | 20 ++ gl/m4/base64.m4 | 16 ++ gl/m4/floorf.m4 | 62 +++++ gl/m4/gnulib-cache.m4 | 4 +- gl/m4/gnulib-comp.m4 | 12 + gl/m4/math_h.m4 | 66 ++++++ gl/math.h | 442 +++++++++++++++++++++++++++++++++++ gl/math.in.h | 413 +++++++++++++++++++++++++++++++++ gl/ref-add.sed | 10 + gl/ref-del.sed | 5 + gl/stdio.h | 411 +++++++++++++++++++++++++++++++++ gl/stdlib.h | 237 +++++++++++++++++++ gl/string.h | 598 ++++++++++++++++++++++++++++++++++++++++++++++++ gl/unistd.h | 321 ++++++++++++++++++++++++++ lib/Makefile.am | 4 +- lib/base64.c | 50 ---- lib/base64.h | 4 - lib/tests/Makefile.am | 2 +- lib/tests/test_base64.c | 10 +- plugins/check_http.c | 2 +- plugins/check_smtp.c | 6 +- 27 files changed, 3302 insertions(+), 67 deletions(-) create mode 100644 gl/base64.c create mode 100644 gl/base64.h create mode 100644 gl/charset.alias create mode 100644 gl/configmake.h create mode 100644 gl/floor.c create mode 100644 gl/floorf.c create mode 100644 gl/m4/base64.m4 create mode 100644 gl/m4/floorf.m4 create mode 100644 gl/m4/math_h.m4 create mode 100644 gl/math.h create mode 100644 gl/math.in.h create mode 100644 gl/ref-add.sed create mode 100644 gl/ref-del.sed create mode 100644 gl/stdio.h create mode 100644 gl/stdlib.h create mode 100644 gl/string.h create mode 100644 gl/unistd.h delete mode 100644 lib/base64.c delete mode 100644 lib/base64.h diff --git a/gl/Makefile.am b/gl/Makefile.am index 92c675ea..1eefee9d 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl dirname fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf AUTOMAKE_OPTIONS = 1.5 gnits @@ -89,6 +89,12 @@ MOSTLYCLEANDIRS += arpa ## end gnulib module arpa_inet +## begin gnulib module base64 + +libgnu_a_SOURCES += base64.h base64.c + +## end gnulib module base64 + ## begin gnulib module c-strtod @@ -219,6 +225,15 @@ EXTRA_DIST += float.in.h ## end gnulib module float +## begin gnulib module floorf + + +EXTRA_DIST += floor.c floorf.c + +EXTRA_libgnu_a_SOURCES += floor.c floorf.c + +## end gnulib module floorf + ## begin gnulib module fsusage @@ -415,6 +430,70 @@ EXTRA_libgnu_a_SOURCES += malloc.c ## end gnulib module malloc-posix +## begin gnulib module math + +BUILT_SOURCES += math.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +math.h: math.in.h + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_MATH_H''@|$(NEXT_MATH_H)|g' \ + -e 's|@''GNULIB_CEILF''@|$(GNULIB_CEILF)|g' \ + -e 's|@''GNULIB_CEILL''@|$(GNULIB_CEILL)|g' \ + -e 's|@''GNULIB_FLOORF''@|$(GNULIB_FLOORF)|g' \ + -e 's|@''GNULIB_FLOORL''@|$(GNULIB_FLOORL)|g' \ + -e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \ + -e 's|@''GNULIB_FREXPL''@|$(GNULIB_FREXPL)|g' \ + -e 's|@''GNULIB_ISFINITE''@|$(GNULIB_ISFINITE)|g' \ + -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \ + -e 's|@''GNULIB_MATHL''@|$(GNULIB_MATHL)|g' \ + -e 's|@''GNULIB_ROUND''@|$(GNULIB_ROUND)|g' \ + -e 's|@''GNULIB_ROUNDF''@|$(GNULIB_ROUNDF)|g' \ + -e 's|@''GNULIB_ROUNDL''@|$(GNULIB_ROUNDL)|g' \ + -e 's|@''GNULIB_SIGNBIT''@|$(GNULIB_SIGNBIT)|g' \ + -e 's|@''GNULIB_TRUNC''@|$(GNULIB_TRUNC)|g' \ + -e 's|@''GNULIB_TRUNCF''@|$(GNULIB_TRUNCF)|g' \ + -e 's|@''GNULIB_TRUNCL''@|$(GNULIB_TRUNCL)|g' \ + -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ + -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ + -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ + -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \ + -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ + -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \ + -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ + -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ + -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \ + -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \ + -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \ + -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ + -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ + -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ + -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ + -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ + -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \ + -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \ + -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ + -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ + -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \ + -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ + -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ + -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ + -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ + -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \ + -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + < $(srcdir)/math.in.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += math.h math.h-t + +EXTRA_DIST += math.in.h + +## end gnulib module math + ## begin gnulib module mountlist diff --git a/gl/base64.c b/gl/base64.c new file mode 100644 index 00000000..e67075d1 --- /dev/null +++ b/gl/base64.c @@ -0,0 +1,425 @@ +/* base64.c -- Encode binary data using printable characters. + Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Simon Josefsson. Partially adapted from GNU MailUtils + * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review + * from Paul Eggert, Bruno Haible, and Stepan Kasal. + * + * See also RFC 3548 . + * + * Be careful with error checking. Here is how you would typically + * use these functions: + * + * bool ok = base64_decode_alloc (in, inlen, &out, &outlen); + * if (!ok) + * FAIL: input was not valid base64 + * if (out == NULL) + * FAIL: memory allocation error + * OK: data in OUT/OUTLEN + * + * size_t outlen = base64_encode_alloc (in, inlen, &out); + * if (out == NULL && outlen == 0 && inlen != 0) + * FAIL: input too long + * if (out == NULL) + * FAIL: memory allocation error + * OK: data in OUT/OUTLEN. + * + */ + +#include + +/* Get prototype. */ +#include "base64.h" + +/* Get malloc. */ +#include + +/* Get UCHAR_MAX. */ +#include + +/* C89 compliant way to cast 'char' to 'unsigned char'. */ +static inline unsigned char +to_uchar (char ch) +{ + return ch; +} + +/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN. + If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as + possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero + terminate the output buffer. */ +void +base64_encode (const char *restrict in, size_t inlen, + char *restrict out, size_t outlen) +{ + static const char b64str[64] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + while (inlen && outlen) + { + *out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f]; + if (!--outlen) + break; + *out++ = b64str[((to_uchar (in[0]) << 4) + + (--inlen ? to_uchar (in[1]) >> 4 : 0)) + & 0x3f]; + if (!--outlen) + break; + *out++ = + (inlen + ? b64str[((to_uchar (in[1]) << 2) + + (--inlen ? to_uchar (in[2]) >> 6 : 0)) + & 0x3f] + : '='); + if (!--outlen) + break; + *out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '='; + if (!--outlen) + break; + if (inlen) + inlen--; + if (inlen) + in += 3; + } + + if (outlen) + *out = '\0'; +} + +/* Allocate a buffer and store zero terminated base64 encoded data + from array IN of size INLEN, returning BASE64_LENGTH(INLEN), i.e., + the length of the encoded data, excluding the terminating zero. On + return, the OUT variable will hold a pointer to newly allocated + memory that must be deallocated by the caller. If output string + length would overflow, 0 is returned and OUT is set to NULL. If + memory allocation failed, OUT is set to NULL, and the return value + indicates length of the requested memory block, i.e., + BASE64_LENGTH(inlen) + 1. */ +size_t +base64_encode_alloc (const char *in, size_t inlen, char **out) +{ + size_t outlen = 1 + BASE64_LENGTH (inlen); + + /* Check for overflow in outlen computation. + * + * If there is no overflow, outlen >= inlen. + * + * If the operation (inlen + 2) overflows then it yields at most +1, so + * outlen is 0. + * + * If the multiplication overflows, we lose at least half of the + * correct value, so the result is < ((inlen + 2) / 3) * 2, which is + * less than (inlen + 2) * 0.66667, which is less than inlen as soon as + * (inlen > 4). + */ + if (inlen > outlen) + { + *out = NULL; + return 0; + } + + *out = malloc (outlen); + if (!*out) + return outlen; + + base64_encode (in, inlen, *out, outlen); + + return outlen - 1; +} + +/* With this approach this file works independent of the charset used + (think EBCDIC). However, it does assume that the characters in the + Base64 alphabet (A-Za-z0-9+/) are encoded in 0..255. POSIX + 1003.1-2001 require that char and unsigned char are 8-bit + quantities, though, taking care of that problem. But this may be a + potential problem on non-POSIX C99 platforms. + + IBM C V6 for AIX mishandles "#define B64(x) ...'x'...", so use "_" + as the formal parameter rather than "x". */ +#define B64(_) \ + ((_) == 'A' ? 0 \ + : (_) == 'B' ? 1 \ + : (_) == 'C' ? 2 \ + : (_) == 'D' ? 3 \ + : (_) == 'E' ? 4 \ + : (_) == 'F' ? 5 \ + : (_) == 'G' ? 6 \ + : (_) == 'H' ? 7 \ + : (_) == 'I' ? 8 \ + : (_) == 'J' ? 9 \ + : (_) == 'K' ? 10 \ + : (_) == 'L' ? 11 \ + : (_) == 'M' ? 12 \ + : (_) == 'N' ? 13 \ + : (_) == 'O' ? 14 \ + : (_) == 'P' ? 15 \ + : (_) == 'Q' ? 16 \ + : (_) == 'R' ? 17 \ + : (_) == 'S' ? 18 \ + : (_) == 'T' ? 19 \ + : (_) == 'U' ? 20 \ + : (_) == 'V' ? 21 \ + : (_) == 'W' ? 22 \ + : (_) == 'X' ? 23 \ + : (_) == 'Y' ? 24 \ + : (_) == 'Z' ? 25 \ + : (_) == 'a' ? 26 \ + : (_) == 'b' ? 27 \ + : (_) == 'c' ? 28 \ + : (_) == 'd' ? 29 \ + : (_) == 'e' ? 30 \ + : (_) == 'f' ? 31 \ + : (_) == 'g' ? 32 \ + : (_) == 'h' ? 33 \ + : (_) == 'i' ? 34 \ + : (_) == 'j' ? 35 \ + : (_) == 'k' ? 36 \ + : (_) == 'l' ? 37 \ + : (_) == 'm' ? 38 \ + : (_) == 'n' ? 39 \ + : (_) == 'o' ? 40 \ + : (_) == 'p' ? 41 \ + : (_) == 'q' ? 42 \ + : (_) == 'r' ? 43 \ + : (_) == 's' ? 44 \ + : (_) == 't' ? 45 \ + : (_) == 'u' ? 46 \ + : (_) == 'v' ? 47 \ + : (_) == 'w' ? 48 \ + : (_) == 'x' ? 49 \ + : (_) == 'y' ? 50 \ + : (_) == 'z' ? 51 \ + : (_) == '0' ? 52 \ + : (_) == '1' ? 53 \ + : (_) == '2' ? 54 \ + : (_) == '3' ? 55 \ + : (_) == '4' ? 56 \ + : (_) == '5' ? 57 \ + : (_) == '6' ? 58 \ + : (_) == '7' ? 59 \ + : (_) == '8' ? 60 \ + : (_) == '9' ? 61 \ + : (_) == '+' ? 62 \ + : (_) == '/' ? 63 \ + : -1) + +static const signed char b64[0x100] = { + B64 (0), B64 (1), B64 (2), B64 (3), + B64 (4), B64 (5), B64 (6), B64 (7), + B64 (8), B64 (9), B64 (10), B64 (11), + B64 (12), B64 (13), B64 (14), B64 (15), + B64 (16), B64 (17), B64 (18), B64 (19), + B64 (20), B64 (21), B64 (22), B64 (23), + B64 (24), B64 (25), B64 (26), B64 (27), + B64 (28), B64 (29), B64 (30), B64 (31), + B64 (32), B64 (33), B64 (34), B64 (35), + B64 (36), B64 (37), B64 (38), B64 (39), + B64 (40), B64 (41), B64 (42), B64 (43), + B64 (44), B64 (45), B64 (46), B64 (47), + B64 (48), B64 (49), B64 (50), B64 (51), + B64 (52), B64 (53), B64 (54), B64 (55), + B64 (56), B64 (57), B64 (58), B64 (59), + B64 (60), B64 (61), B64 (62), B64 (63), + B64 (64), B64 (65), B64 (66), B64 (67), + B64 (68), B64 (69), B64 (70), B64 (71), + B64 (72), B64 (73), B64 (74), B64 (75), + B64 (76), B64 (77), B64 (78), B64 (79), + B64 (80), B64 (81), B64 (82), B64 (83), + B64 (84), B64 (85), B64 (86), B64 (87), + B64 (88), B64 (89), B64 (90), B64 (91), + B64 (92), B64 (93), B64 (94), B64 (95), + B64 (96), B64 (97), B64 (98), B64 (99), + B64 (100), B64 (101), B64 (102), B64 (103), + B64 (104), B64 (105), B64 (106), B64 (107), + B64 (108), B64 (109), B64 (110), B64 (111), + B64 (112), B64 (113), B64 (114), B64 (115), + B64 (116), B64 (117), B64 (118), B64 (119), + B64 (120), B64 (121), B64 (122), B64 (123), + B64 (124), B64 (125), B64 (126), B64 (127), + B64 (128), B64 (129), B64 (130), B64 (131), + B64 (132), B64 (133), B64 (134), B64 (135), + B64 (136), B64 (137), B64 (138), B64 (139), + B64 (140), B64 (141), B64 (142), B64 (143), + B64 (144), B64 (145), B64 (146), B64 (147), + B64 (148), B64 (149), B64 (150), B64 (151), + B64 (152), B64 (153), B64 (154), B64 (155), + B64 (156), B64 (157), B64 (158), B64 (159), + B64 (160), B64 (161), B64 (162), B64 (163), + B64 (164), B64 (165), B64 (166), B64 (167), + B64 (168), B64 (169), B64 (170), B64 (171), + B64 (172), B64 (173), B64 (174), B64 (175), + B64 (176), B64 (177), B64 (178), B64 (179), + B64 (180), B64 (181), B64 (182), B64 (183), + B64 (184), B64 (185), B64 (186), B64 (187), + B64 (188), B64 (189), B64 (190), B64 (191), + B64 (192), B64 (193), B64 (194), B64 (195), + B64 (196), B64 (197), B64 (198), B64 (199), + B64 (200), B64 (201), B64 (202), B64 (203), + B64 (204), B64 (205), B64 (206), B64 (207), + B64 (208), B64 (209), B64 (210), B64 (211), + B64 (212), B64 (213), B64 (214), B64 (215), + B64 (216), B64 (217), B64 (218), B64 (219), + B64 (220), B64 (221), B64 (222), B64 (223), + B64 (224), B64 (225), B64 (226), B64 (227), + B64 (228), B64 (229), B64 (230), B64 (231), + B64 (232), B64 (233), B64 (234), B64 (235), + B64 (236), B64 (237), B64 (238), B64 (239), + B64 (240), B64 (241), B64 (242), B64 (243), + B64 (244), B64 (245), B64 (246), B64 (247), + B64 (248), B64 (249), B64 (250), B64 (251), + B64 (252), B64 (253), B64 (254), B64 (255) +}; + +#if UCHAR_MAX == 255 +# define uchar_in_range(c) true +#else +# define uchar_in_range(c) ((c) <= 255) +#endif + +/* Return true if CH is a character from the Base64 alphabet, and + false otherwise. Note that '=' is padding and not considered to be + part of the alphabet. */ +bool +isbase64 (char ch) +{ + return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)]; +} + +/* Decode base64 encoded input array IN of length INLEN to output + array OUT that can hold *OUTLEN bytes. Return true if decoding was + successful, i.e. if the input was valid base64 data, false + otherwise. If *OUTLEN is too small, as many bytes as possible will + be written to OUT. On return, *OUTLEN holds the length of decoded + bytes in OUT. Note that as soon as any non-alphabet characters are + encountered, decoding is stopped and false is returned. This means + that, when applicable, you must remove any line terminators that is + part of the data stream before calling this function. */ +bool +base64_decode (const char *restrict in, size_t inlen, + char *restrict out, size_t *outlen) +{ + size_t outleft = *outlen; + + while (inlen >= 2) + { + if (!isbase64 (in[0]) || !isbase64 (in[1])) + break; + + if (outleft) + { + *out++ = ((b64[to_uchar (in[0])] << 2) + | (b64[to_uchar (in[1])] >> 4)); + outleft--; + } + + if (inlen == 2) + break; + + if (in[2] == '=') + { + if (inlen != 4) + break; + + if (in[3] != '=') + break; + + } + else + { + if (!isbase64 (in[2])) + break; + + if (outleft) + { + *out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0) + | (b64[to_uchar (in[2])] >> 2)); + outleft--; + } + + if (inlen == 3) + break; + + if (in[3] == '=') + { + if (inlen != 4) + break; + } + else + { + if (!isbase64 (in[3])) + break; + + if (outleft) + { + *out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0) + | b64[to_uchar (in[3])]); + outleft--; + } + } + } + + in += 4; + inlen -= 4; + } + + *outlen -= outleft; + + if (inlen != 0) + return false; + + return true; +} + +/* Allocate an output buffer in *OUT, and decode the base64 encoded + data stored in IN of size INLEN to the *OUT buffer. On return, the + size of the decoded data is stored in *OUTLEN. OUTLEN may be NULL, + if the caller is not interested in the decoded length. *OUT may be + NULL to indicate an out of memory error, in which case *OUTLEN + contains the size of the memory block needed. The function returns + true on successful decoding and memory allocation errors. (Use the + *OUT and *OUTLEN parameters to differentiate between successful + decoding and memory error.) The function returns false if the + input was invalid, in which case *OUT is NULL and *OUTLEN is + undefined. */ +bool +base64_decode_alloc (const char *in, size_t inlen, char **out, + size_t *outlen) +{ + /* This may allocate a few bytes too much, depending on input, + but it's not worth the extra CPU time to compute the exact amount. + The exact amount is 3 * inlen / 4, minus 1 if the input ends + with "=" and minus another 1 if the input ends with "==". + Dividing before multiplying avoids the possibility of overflow. */ + size_t needlen = 3 * (inlen / 4) + 2; + + *out = malloc (needlen); + if (!*out) + return true; + + if (!base64_decode (in, inlen, *out, &needlen)) + { + free (*out); + *out = NULL; + return false; + } + + if (outlen) + *outlen = needlen; + + return true; +} diff --git a/gl/base64.h b/gl/base64.h new file mode 100644 index 00000000..1f9b203e --- /dev/null +++ b/gl/base64.h @@ -0,0 +1,45 @@ +/* base64.h -- Encode binary data using printable characters. + Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. + Written by Simon Josefsson. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef BASE64_H +# define BASE64_H + +/* Get size_t. */ +# include + +/* Get bool. */ +# include + +/* This uses that the expression (n+(k-1))/k means the smallest + integer >= n/k, i.e., the ceiling of n/k. */ +# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4) + +extern bool isbase64 (char ch); + +extern void base64_encode (const char *restrict in, size_t inlen, + char *restrict out, size_t outlen); + +extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out); + +extern bool base64_decode (const char *restrict in, size_t inlen, + char *restrict out, size_t *outlen); + +extern bool base64_decode_alloc (const char *in, size_t inlen, + char **out, size_t *outlen); + +#endif /* BASE64_H */ diff --git a/gl/charset.alias b/gl/charset.alias new file mode 100644 index 00000000..d9501e2b --- /dev/null +++ b/gl/charset.alias @@ -0,0 +1,5 @@ +# This file contains a table of character encoding aliases, +# suitable for operating system 'linux-gnu'. +# It was automatically generated from config.charset. +# Packages using this file: +ISO_646.IRV:1983 ASCII diff --git a/gl/configmake.h b/gl/configmake.h new file mode 100644 index 00000000..f73bc381 --- /dev/null +++ b/gl/configmake.h @@ -0,0 +1,25 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#define PREFIX "/usr/local/nagios" +#define EXEC_PREFIX "/usr/local/nagios" +#define BINDIR "/usr/local/nagios/bin" +#define SBINDIR "/usr/local/nagios/sbin" +#define LIBEXECDIR "/usr/local/nagios/libexec" +#define DATAROOTDIR "/usr/local/nagios/share" +#define DATADIR "/usr/local/nagios/share" +#define SYSCONFDIR "/usr/local/nagios/etc" +#define SHAREDSTATEDIR "/usr/local/nagios/com" +#define LOCALSTATEDIR "/usr/local/nagios/var" +#define INCLUDEDIR "/usr/local/nagios/include" +#define OLDINCLUDEDIR "/usr/include" +#define DOCDIR "/usr/local/nagios/share/doc/nagios-plugins" +#define INFODIR "/usr/local/nagios/share/info" +#define HTMLDIR "/usr/local/nagios/share/doc/nagios-plugins" +#define DVIDIR "/usr/local/nagios/share/doc/nagios-plugins" +#define PDFDIR "/usr/local/nagios/share/doc/nagios-plugins" +#define PSDIR "/usr/local/nagios/share/doc/nagios-plugins" +#define LIBDIR "/usr/local/nagios/lib" +#define LOCALEDIR "/usr/local/nagios/share/locale" +#define MANDIR "/usr/local/nagios/share/man" +#define PKGDATADIR "/usr/local/nagios/share/nagios-plugins" +#define PKGINCLUDEDIR "/usr/local/nagios/include/nagios-plugins" +#define PKGLIBDIR "/usr/local/nagios/lib/nagios-plugins" diff --git a/gl/floor.c b/gl/floor.c new file mode 100644 index 00000000..05a6591a --- /dev/null +++ b/gl/floor.c @@ -0,0 +1,93 @@ +/* Round towards negative infinity. + Copyright (C) 2007 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +/* Specification. */ +#include + +#include + +#ifdef USE_LONG_DOUBLE +# define FUNC floorl +# define DOUBLE long double +# define MANT_DIG LDBL_MANT_DIG +# define L_(literal) literal##L +#elif ! defined USE_FLOAT +# define FUNC floor +# define DOUBLE double +# define MANT_DIG DBL_MANT_DIG +# define L_(literal) literal +#else /* defined USE_FLOAT */ +# define FUNC floorf +# define DOUBLE float +# define MANT_DIG FLT_MANT_DIG +# define L_(literal) literal##f +#endif + +/* 2^(MANT_DIG-1). */ +static const DOUBLE TWO_MANT_DIG = + /* Assume MANT_DIG <= 5 * 31. + Use the identity + n = floor(n/5) + floor((n+1)/5) + ... + floor((n+4)/5). */ + (DOUBLE) (1U << ((MANT_DIG - 1) / 5)) + * (DOUBLE) (1U << ((MANT_DIG - 1 + 1) / 5)) + * (DOUBLE) (1U << ((MANT_DIG - 1 + 2) / 5)) + * (DOUBLE) (1U << ((MANT_DIG - 1 + 3) / 5)) + * (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5)); + +DOUBLE +FUNC (DOUBLE x) +{ + /* The use of 'volatile' guarantees that excess precision bits are dropped + at each addition step and before the following comparison at the caller's + site. It is necessary on x86 systems where double-floats are not IEEE + compliant by default, to avoid that the results become platform and compiler + option dependent. 'volatile' is a portable alternative to gcc's + -ffloat-store option. */ + volatile DOUBLE y = x; + volatile DOUBLE z = y; + + if (z > L_(0.0)) + { + /* Avoid rounding errors for values near 2^k, where k >= MANT_DIG-1. */ + if (z < TWO_MANT_DIG) + { + /* Round to the next integer (nearest or up or down, doesn't matter). */ + z += TWO_MANT_DIG; + z -= TWO_MANT_DIG; + /* Enforce rounding down. */ + if (z > y) + z -= L_(1.0); + } + } + else if (z < L_(0.0)) + { + /* Avoid rounding errors for values near -2^k, where k >= MANT_DIG-1. */ + if (z > - TWO_MANT_DIG) + { + /* Round to the next integer (nearest or up or down, doesn't matter). */ + z -= TWO_MANT_DIG; + z += TWO_MANT_DIG; + /* Enforce rounding down. */ + if (z > y) + z -= L_(1.0); + } + } + return z; +} diff --git a/gl/floorf.c b/gl/floorf.c new file mode 100644 index 00000000..f0aff338 --- /dev/null +++ b/gl/floorf.c @@ -0,0 +1,20 @@ +/* Round towards negative infinity. + Copyright (C) 2007 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +#define USE_FLOAT +#include "floor.c" diff --git a/gl/m4/base64.m4 b/gl/m4/base64.m4 new file mode 100644 index 00000000..24801efa --- /dev/null +++ b/gl/m4/base64.m4 @@ -0,0 +1,16 @@ +# base64.m4 serial 3 +dnl Copyright (C) 2004, 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_BASE64], +[ + gl_PREREQ_BASE64 +]) + +# Prerequisites of lib/base64.c. +AC_DEFUN([gl_PREREQ_BASE64], [ + AC_REQUIRE([AC_C_INLINE]) + AC_REQUIRE([AC_C_RESTRICT]) +]) diff --git a/gl/m4/floorf.m4 b/gl/m4/floorf.m4 new file mode 100644 index 00000000..8cdaa946 --- /dev/null +++ b/gl/m4/floorf.m4 @@ -0,0 +1,62 @@ +# floorf.m4 serial 3 +dnl Copyright (C) 2007 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_FLOORF], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + dnl Persuade glibc to declare floorf(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + dnl Test whether floorf() is declared. + AC_CHECK_DECLS([floorf], , , [#include ]) + if test "$ac_cv_have_decl_floorf" = yes; then + dnl Test whether floorf() can be used without libm. + gl_FUNC_FLOORF_LIBS + if test "$FLOORF_LIBM" = "?"; then + dnl Sun C 5.0 on Solaris declares floorf() and has it in the system-wide + dnl libm.so, but not in the libm.so that the compiler uses. + REPLACE_FLOORF=1 + fi + else + REPLACE_FLOORF=1 + fi + if test $REPLACE_FLOORF = 1; then + AC_LIBOBJ([floorf]) + FLOORF_LIBM= + fi + AC_SUBST([REPLACE_FLOORF]) + AC_SUBST([FLOORF_LIBM]) +]) + +# Determines the libraries needed to get the floorf() function. +# Sets FLOORF_LIBM. +AC_DEFUN([gl_FUNC_FLOORF_LIBS], +[ + AC_CACHE_VAL([gl_cv_func_floorf_libm], [ + gl_cv_func_floorf_libm=? + AC_TRY_LINK([ + #ifndef __NO_MATH_INLINES + # define __NO_MATH_INLINES 1 /* for glibc */ + #endif + #include + float x;], + [x = floorf(x);], + [gl_cv_func_floorf_libm=]) + if test "$gl_cv_func_floorf_libm" = "?"; then + save_LIBS="$LIBS" + LIBS="$LIBS -lm" + AC_TRY_LINK([ + #ifndef __NO_MATH_INLINES + # define __NO_MATH_INLINES 1 /* for glibc */ + #endif + #include + float x;], + [x = floorf(x);], + [gl_cv_func_floorf_libm="-lm"]) + LIBS="$save_LIBS" + fi + ]) + FLOORF_LIBM="$gl_cv_func_floorf_libm" +]) diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index 6da4d657..302dc191 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -15,11 +15,11 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl dirname fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf +# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) -gl_MODULES([dirname fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf]) +gl_MODULES([base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf]) gl_AVOID([]) gl_SOURCE_BASE([gl]) gl_M4_BASE([gl/m4]) diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index a17e36ad..85ad2e9d 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -44,6 +44,7 @@ AC_DEFUN([gl_INIT], gl_FUNC_ALLOCA gl_HEADER_ARPA_INET AC_PROG_MKDIR_P + gl_FUNC_BASE64 gl_C_STRTOD gl_CLOEXEC gl_DIRNAME @@ -56,6 +57,8 @@ AC_DEFUN([gl_INIT], gl_FCNTL_SAFER gl_MODULE_INDICATOR([fcntl-safer]) gl_FLOAT_H + gl_FUNC_FLOORF + gl_MATH_MODULE_INDICATOR([floorf]) gl_FSUSAGE gl_GETADDRINFO gl_FUNC_GETHOSTNAME @@ -74,6 +77,7 @@ AC_DEFUN([gl_INIT], AC_DEFINE([GNULIB_MALLOC_GNU], 1, [Define to indicate the 'malloc' module.]) gl_FUNC_MALLOC_POSIX gl_STDLIB_MODULE_INDICATOR([malloc-posix]) + gl_MATH_H gl_MOUNTLIST gl_HEADER_NETINET_IN AC_PROG_MKDIR_P @@ -240,6 +244,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/alloca.in.h lib/asnprintf.c lib/asprintf.c + lib/base64.c + lib/base64.h lib/basename.c lib/c-strtod.c lib/c-strtod.h @@ -259,6 +265,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/fd-safer.c lib/float+.h lib/float.in.h + lib/floor.c + lib/floorf.c lib/fsusage.c lib/fsusage.h lib/full-read.c @@ -281,6 +289,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/localcharset.c lib/localcharset.h lib/malloc.c + lib/math.in.h lib/mountlist.c lib/mountlist.h lib/netinet_in.in.h @@ -333,6 +342,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/absolute-header.m4 m4/alloca.m4 m4/arpa_inet_h.m4 + m4/base64.m4 m4/c-strtod.m4 m4/cloexec.m4 m4/codeset.m4 @@ -345,6 +355,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/extensions.m4 m4/fcntl-safer.m4 m4/float_h.m4 + m4/floorf.m4 m4/fstypename.m4 m4/fsusage.m4 m4/getaddrinfo.m4 @@ -376,6 +387,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/longlong.m4 m4/ls-mntd-fs.m4 m4/malloc.m4 + m4/math_h.m4 m4/mountlist.m4 m4/netinet_in_h.m4 m4/nls.m4 diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4 new file mode 100644 index 00000000..dd99e7f2 --- /dev/null +++ b/gl/m4/math_h.m4 @@ -0,0 +1,66 @@ +# math_h.m4 serial 9 +dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_MATH_H], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + gl_CHECK_NEXT_HEADERS([math.h]) +]) + +AC_DEFUN([gl_MATH_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 +]) + +AC_DEFUN([gl_MATH_H_DEFAULTS], +[ + GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF]) + GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL]) + GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF]) + GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL]) + GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP]) + GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL]) + GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE]) + GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL]) + GNULIB_MATHL=0; AC_SUBST([GNULIB_MATHL]) + GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND]) + GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF]) + GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL]) + GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT]) + GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC]) + GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF]) + GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) + HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) + HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) + HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) + HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) + HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) + HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) + HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) + HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) + HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) + HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) + HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) + HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) + HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) + REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) + REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) + REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) + REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL]) + REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) + REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) + REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) + REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) + REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) + REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) + REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) + REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT]) + REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC]) +]) diff --git a/gl/math.h b/gl/math.h new file mode 100644 index 00000000..9db986e0 --- /dev/null +++ b/gl/math.h @@ -0,0 +1,442 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* A GNU-like . + + Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _GL_MATH_H + +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_MATH_H +#define _GL_MATH_H + + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp in *EXPPTR and return mantissa. */ +#if 0 +# if 0 +# define frexp rpl_frexp +extern double frexp (double x, int *expptr); +# endif +#elif defined GNULIB_POSIXCHECK +# undef frexp +# define frexp(x,e) \ + (GL_LINK_WARNING ("frexp is unportable - " \ + "use gnulib module frexp for portability"), \ + frexp (x, e)) +#endif + + +#if 0 || !1 +extern long double acosl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef acosl +# define acosl(x) \ + (GL_LINK_WARNING ("acosl is unportable - " \ + "use gnulib module mathl for portability"), \ + acosl (x)) +#endif + + +#if 0 || !1 +extern long double asinl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef asinl +# define asinl(x) \ + (GL_LINK_WARNING ("asinl is unportable - " \ + "use gnulib module mathl for portability"), \ + asinl (x)) +#endif + + +#if 0 || !1 +extern long double atanl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef atanl +# define atanl(x) \ + (GL_LINK_WARNING ("atanl is unportable - " \ + "use gnulib module mathl for portability"), \ + atanl (x)) +#endif + + +#if 0 +# if 0 +# define ceilf rpl_ceilf +extern float ceilf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ceilf +# define ceilf(x) \ + (GL_LINK_WARNING ("ceilf is unportable - " \ + "use gnulib module ceilf for portability"), \ + ceilf (x)) +#endif + +#if 0 +# if 0 +# define ceill rpl_ceill +extern long double ceill (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ceill +# define ceill(x) \ + (GL_LINK_WARNING ("ceill is unportable - " \ + "use gnulib module ceill for portability"), \ + ceill (x)) +#endif + + +#if 0 || !1 +extern long double cosl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef cosl +# define cosl(x) \ + (GL_LINK_WARNING ("cosl is unportable - " \ + "use gnulib module mathl for portability"), \ + cosl (x)) +#endif + + +#if 0 || !1 +extern long double expl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef expl +# define expl(x) \ + (GL_LINK_WARNING ("expl is unportable - " \ + "use gnulib module mathl for portability"), \ + expl (x)) +#endif + + +#if 1 +# if 0 +# define floorf rpl_floorf +extern float floorf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef floorf +# define floorf(x) \ + (GL_LINK_WARNING ("floorf is unportable - " \ + "use gnulib module floorf for portability"), \ + floorf (x)) +#endif + +#if 0 +# if 0 +# define floorl rpl_floorl +extern long double floorl (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef floorl +# define floorl(x) \ + (GL_LINK_WARNING ("floorl is unportable - " \ + "use gnulib module floorl for portability"), \ + floorl (x)) +#endif + + +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp in *EXPPTR and return mantissa. */ +#if 0 && 0 +# define frexpl rpl_frexpl +#endif +#if (0 && 0) || !1 +extern long double frexpl (long double x, int *expptr); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef frexpl +# define frexpl(x,e) \ + (GL_LINK_WARNING ("frexpl is unportable - " \ + "use gnulib module frexpl for portability"), \ + frexpl (x, e)) +#endif + + +/* Return x * 2^exp. */ +#if 0 && 0 +# define ldexpl rpl_ldexpl +#endif +#if (0 && 0) || !1 +extern long double ldexpl (long double x, int exp); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef ldexpl +# define ldexpl(x,e) \ + (GL_LINK_WARNING ("ldexpl is unportable - " \ + "use gnulib module ldexpl for portability"), \ + ldexpl (x, e)) +#endif + + +#if 0 || !1 +extern long double logl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef logl +# define logl(x) \ + (GL_LINK_WARNING ("logl is unportable - " \ + "use gnulib module mathl for portability"), \ + logl (x)) +#endif + + +#if 0 +# if 0 +# undef roundf +# define roundf rpl_roundf +extern float roundf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef roundf +# define roundf(x) \ + (GL_LINK_WARNING ("roundf is unportable - " \ + "use gnulib module roundf for portability"), \ + roundf (x)) +#endif + +#if 0 +# if 0 +# undef round +# define round rpl_round +extern double round (double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef round +# define round(x) \ + (GL_LINK_WARNING ("round is unportable - " \ + "use gnulib module round for portability"), \ + round (x)) +#endif + +#if 0 +# if 0 +# undef roundl +# define roundl rpl_roundl +extern long double roundl (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef roundl +# define roundl(x) \ + (GL_LINK_WARNING ("roundl is unportable - " \ + "use gnulib module roundl for portability"), \ + roundl (x)) +#endif + + +#if 0 || !1 +extern long double sinl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef sinl +# define sinl(x) \ + (GL_LINK_WARNING ("sinl is unportable - " \ + "use gnulib module mathl for portability"), \ + sinl (x)) +#endif + + +#if 0 || !1 +extern long double sqrtl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef sqrtl +# define sqrtl(x) \ + (GL_LINK_WARNING ("sqrtl is unportable - " \ + "use gnulib module mathl for portability"), \ + sqrtl (x)) +#endif + + +#if 0 || !1 +extern long double tanl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef tanl +# define tanl(x) \ + (GL_LINK_WARNING ("tanl is unportable - " \ + "use gnulib module mathl for portability"), \ + tanl (x)) +#endif + + +#if 0 +# if !1 +# define truncf rpl_truncf +extern float truncf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef truncf +# define truncf(x) \ + (GL_LINK_WARNING ("truncf is unportable - " \ + "use gnulib module truncf for portability"), \ + truncf (x)) +#endif + +#if 0 +# if !1 +# define trunc rpl_trunc +extern double trunc (double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef trunc +# define trunc(x) \ + (GL_LINK_WARNING ("trunc is unportable - " \ + "use gnulib module trunc for portability"), \ + trunc (x)) +#endif + +#if 0 +# if !1 +# define truncl rpl_truncl +extern long double truncl (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef truncl +# define truncl(x) \ + (GL_LINK_WARNING ("truncl is unportable - " \ + "use gnulib module truncl for portability"), \ + truncl (x)) +#endif + + +#if 0 +# if 0 +extern int gl_isfinitef (float x); +extern int gl_isfinited (double x); +extern int gl_isfinitel (long double x); +# undef isfinite +# define isfinite(x) \ + (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ + sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ + gl_isfinitef (x)) +# endif +#elif defined GNULIB_POSIXCHECK + /* How to override a macro? */ +#endif + + +#if 0 +# if 0 +# undef signbit + /* GCC 4.0 and newer provides three built-ins for signbit. */ +# define signbit(x) \ + (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ + sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ + __builtin_signbitf (x)) +# endif +# if 0 +# undef signbit +extern int gl_signbitf (float arg); +extern int gl_signbitd (double arg); +extern int gl_signbitl (long double arg); +# if __GNUC__ >= 2 && !__STRICT_ANSI__ +# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT +# define gl_signbitf(arg) \ + ({ union { float _value; \ + unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ + }) +# endif +# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT +# define gl_signbitd(arg) \ + ({ union { double _value; \ + unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ + }) +# endif +# if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT +# define gl_signbitl(arg) \ + ({ union { long double _value; \ + unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ + }) +# endif +# endif +# define signbit(x) \ + (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ + sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ + gl_signbitf (x)) +# endif +#elif defined GNULIB_POSIXCHECK + /* How to override a macro? */ +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_MATH_H */ +#endif /* _GL_MATH_H */ diff --git a/gl/math.in.h b/gl/math.in.h new file mode 100644 index 00000000..c3515d73 --- /dev/null +++ b/gl/math.in.h @@ -0,0 +1,413 @@ +/* A GNU-like . + + Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _GL_MATH_H + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_MATH_H@ + +#ifndef _GL_MATH_H +#define _GL_MATH_H + + +/* The definition of GL_LINK_WARNING is copied here. */ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp in *EXPPTR and return mantissa. */ +#if @GNULIB_FREXP@ +# if @REPLACE_FREXP@ +# define frexp rpl_frexp +extern double frexp (double x, int *expptr); +# endif +#elif defined GNULIB_POSIXCHECK +# undef frexp +# define frexp(x,e) \ + (GL_LINK_WARNING ("frexp is unportable - " \ + "use gnulib module frexp for portability"), \ + frexp (x, e)) +#endif + + +#if @GNULIB_MATHL@ || !@HAVE_DECL_ACOSL@ +extern long double acosl (long double x); +#endif +#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +# undef acosl +# define acosl(x) \ + (GL_LINK_WARNING ("acosl is unportable - " \ + "use gnulib module mathl for portability"), \ + acosl (x)) +#endif + + +#if @GNULIB_MATHL@ || !@HAVE_DECL_ASINL@ +extern long double asinl (long double x); +#endif +#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +# undef asinl +# define asinl(x) \ + (GL_LINK_WARNING ("asinl is unportable - " \ + "use gnulib module mathl for portability"), \ + asinl (x)) +#endif + + +#if @GNULIB_MATHL@ || !@HAVE_DECL_ATANL@ +extern long double atanl (long double x); +#endif +#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +# undef atanl +# define atanl(x) \ + (GL_LINK_WARNING ("atanl is unportable - " \ + "use gnulib module mathl for portability"), \ + atanl (x)) +#endif + + +#if @GNULIB_CEILF@ +# if @REPLACE_CEILF@ +# define ceilf rpl_ceilf +extern float ceilf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ceilf +# define ceilf(x) \ + (GL_LINK_WARNING ("ceilf is unportable - " \ + "use gnulib module ceilf for portability"), \ + ceilf (x)) +#endif + +#if @GNULIB_CEILL@ +# if @REPLACE_CEILL@ +# define ceill rpl_ceill +extern long double ceill (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ceill +# define ceill(x) \ + (GL_LINK_WARNING ("ceill is unportable - " \ + "use gnulib module ceill for portability"), \ + ceill (x)) +#endif + + +#if @GNULIB_MATHL@ || !@HAVE_DECL_COSL@ +extern long double cosl (long double x); +#endif +#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +# undef cosl +# define cosl(x) \ + (GL_LINK_WARNING ("cosl is unportable - " \ + "use gnulib module mathl for portability"), \ + cosl (x)) +#endif + + +#if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@ +extern long double expl (long double x); +#endif +#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +# undef expl +# define expl(x) \ + (GL_LINK_WARNING ("expl is unportable - " \ + "use gnulib module mathl for portability"), \ + expl (x)) +#endif + + +#if @GNULIB_FLOORF@ +# if @REPLACE_FLOORF@ +# define floorf rpl_floorf +extern float floorf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef floorf +# define floorf(x) \ + (GL_LINK_WARNING ("floorf is unportable - " \ + "use gnulib module floorf for portability"), \ + floorf (x)) +#endif + +#if @GNULIB_FLOORL@ +# if @REPLACE_FLOORL@ +# define floorl rpl_floorl +extern long double floorl (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef floorl +# define floorl(x) \ + (GL_LINK_WARNING ("floorl is unportable - " \ + "use gnulib module floorl for portability"), \ + floorl (x)) +#endif + + +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp in *EXPPTR and return mantissa. */ +#if @GNULIB_FREXPL@ && @REPLACE_FREXPL@ +# define frexpl rpl_frexpl +#endif +#if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@ +extern long double frexpl (long double x, int *expptr); +#endif +#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK +# undef frexpl +# define frexpl(x,e) \ + (GL_LINK_WARNING ("frexpl is unportable - " \ + "use gnulib module frexpl for portability"), \ + frexpl (x, e)) +#endif + + +/* Return x * 2^exp. */ +#if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ +# define ldexpl rpl_ldexpl +#endif +#if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@ +extern long double ldexpl (long double x, int exp); +#endif +#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK +# undef ldexpl +# define ldexpl(x,e) \ + (GL_LINK_WARNING ("ldexpl is unportable - " \ + "use gnulib module ldexpl for portability"), \ + ldexpl (x, e)) +#endif + + +#if @GNULIB_MATHL@ || !@HAVE_DECL_LOGL@ +extern long double logl (long double x); +#endif +#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +# undef logl +# define logl(x) \ + (GL_LINK_WARNING ("logl is unportable - " \ + "use gnulib module mathl for portability"), \ + logl (x)) +#endif + + +#if @GNULIB_ROUNDF@ +# if @REPLACE_ROUNDF@ +# undef roundf +# define roundf rpl_roundf +extern float roundf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef roundf +# define roundf(x) \ + (GL_LINK_WARNING ("roundf is unportable - " \ + "use gnulib module roundf for portability"), \ + roundf (x)) +#endif + +#if @GNULIB_ROUND@ +# if @REPLACE_ROUND@ +# undef round +# define round rpl_round +extern double round (double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef round +# define round(x) \ + (GL_LINK_WARNING ("round is unportable - " \ + "use gnulib module round for portability"), \ + round (x)) +#endif + +#if @GNULIB_ROUNDL@ +# if @REPLACE_ROUNDL@ +# undef roundl +# define roundl rpl_roundl +extern long double roundl (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef roundl +# define roundl(x) \ + (GL_LINK_WARNING ("roundl is unportable - " \ + "use gnulib module roundl for portability"), \ + roundl (x)) +#endif + + +#if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@ +extern long double sinl (long double x); +#endif +#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +# undef sinl +# define sinl(x) \ + (GL_LINK_WARNING ("sinl is unportable - " \ + "use gnulib module mathl for portability"), \ + sinl (x)) +#endif + + +#if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@ +extern long double sqrtl (long double x); +#endif +#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +# undef sqrtl +# define sqrtl(x) \ + (GL_LINK_WARNING ("sqrtl is unportable - " \ + "use gnulib module mathl for portability"), \ + sqrtl (x)) +#endif + + +#if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@ +extern long double tanl (long double x); +#endif +#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +# undef tanl +# define tanl(x) \ + (GL_LINK_WARNING ("tanl is unportable - " \ + "use gnulib module mathl for portability"), \ + tanl (x)) +#endif + + +#if @GNULIB_TRUNCF@ +# if !@HAVE_DECL_TRUNCF@ +# define truncf rpl_truncf +extern float truncf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef truncf +# define truncf(x) \ + (GL_LINK_WARNING ("truncf is unportable - " \ + "use gnulib module truncf for portability"), \ + truncf (x)) +#endif + +#if @GNULIB_TRUNC@ +# if !@HAVE_DECL_TRUNC@ +# define trunc rpl_trunc +extern double trunc (double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef trunc +# define trunc(x) \ + (GL_LINK_WARNING ("trunc is unportable - " \ + "use gnulib module trunc for portability"), \ + trunc (x)) +#endif + +#if @GNULIB_TRUNCL@ +# if !@HAVE_DECL_TRUNCL@ +# define truncl rpl_truncl +extern long double truncl (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef truncl +# define truncl(x) \ + (GL_LINK_WARNING ("truncl is unportable - " \ + "use gnulib module truncl for portability"), \ + truncl (x)) +#endif + + +#if @GNULIB_ISFINITE@ +# if @REPLACE_ISFINITE@ +extern int gl_isfinitef (float x); +extern int gl_isfinited (double x); +extern int gl_isfinitel (long double x); +# undef isfinite +# define isfinite(x) \ + (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ + sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ + gl_isfinitef (x)) +# endif +#elif defined GNULIB_POSIXCHECK + /* How to override a macro? */ +#endif + + +#if @GNULIB_SIGNBIT@ +# if @REPLACE_SIGNBIT_USING_GCC@ +# undef signbit + /* GCC 4.0 and newer provides three built-ins for signbit. */ +# define signbit(x) \ + (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ + sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ + __builtin_signbitf (x)) +# endif +# if @REPLACE_SIGNBIT@ +# undef signbit +extern int gl_signbitf (float arg); +extern int gl_signbitd (double arg); +extern int gl_signbitl (long double arg); +# if __GNUC__ >= 2 && !__STRICT_ANSI__ +# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT +# define gl_signbitf(arg) \ + ({ union { float _value; \ + unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ + }) +# endif +# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT +# define gl_signbitd(arg) \ + ({ union { double _value; \ + unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ + }) +# endif +# if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT +# define gl_signbitl(arg) \ + ({ union { long double _value; \ + unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ + }) +# endif +# endif +# define signbit(x) \ + (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ + sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ + gl_signbitf (x)) +# endif +#elif defined GNULIB_POSIXCHECK + /* How to override a macro? */ +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_MATH_H */ +#endif /* _GL_MATH_H */ diff --git a/gl/ref-add.sed b/gl/ref-add.sed new file mode 100644 index 00000000..3ac991fe --- /dev/null +++ b/gl/ref-add.sed @@ -0,0 +1,10 @@ +/^# Packages using this file: / { + s/# Packages using this file:// + ta + :a + s/ nagios-plugins / nagios-plugins / + tb + s/ $/ nagios-plugins / + :b + s/^/# Packages using this file:/ +} diff --git a/gl/ref-del.sed b/gl/ref-del.sed new file mode 100644 index 00000000..a48fdb77 --- /dev/null +++ b/gl/ref-del.sed @@ -0,0 +1,5 @@ +/^# Packages using this file: / { + s/# Packages using this file:// + s/ nagios-plugins / / + s/^/# Packages using this file:/ +} diff --git a/gl/stdio.h b/gl/stdio.h new file mode 100644 index 00000000..f09ee831 --- /dev/null +++ b/gl/stdio.h @@ -0,0 +1,411 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* A GNU-like . + + Copyright (C) 2004, 2007-2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#if defined __need_FILE || defined __need___FILE +/* Special invocation convention inside glibc header files. */ + +#include_next + +#else +/* Normal invocation convention. */ + +#ifndef _GL_STDIO_H + +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_STDIO_H +#define _GL_STDIO_H + +#include +#include + +#if (0 && 0) \ + || (0 && 0) \ + || (0 && !1) \ + || (0 && (!1 || 0)) +/* Get off_t and ssize_t. */ +# include +#endif + +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +# define __attribute__(Spec) /* empty */ +# endif +/* The __-protected variants of `format' and `printf' attributes + are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) +# define __format__ format +# define __printf__ printf +# endif +#endif + + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if 0 +# if 0 +# define fprintf rpl_fprintf +extern int fprintf (FILE *fp, const char *format, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fprintf +# define fprintf \ + (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \ + "use gnulib module fprintf-posix for portable " \ + "POSIX compliance"), \ + fprintf) +#endif + +#if 0 +# if 0 +# define vfprintf rpl_vfprintf +extern int vfprintf (FILE *fp, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vfprintf +# define vfprintf(s,f,a) \ + (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \ + "use gnulib module vfprintf-posix for portable " \ + "POSIX compliance"), \ + vfprintf (s, f, a)) +#endif + +#if 0 +# if 0 +/* Don't break __attribute__((format(printf,M,N))). */ +# define printf __printf__ +extern int printf (const char *format, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef printf +# define printf \ + (GL_LINK_WARNING ("printf is not always POSIX compliant - " \ + "use gnulib module printf-posix for portable " \ + "POSIX compliance"), \ + printf) +/* Don't break __attribute__((format(printf,M,N))). */ +# define format(kind,m,n) format (__##kind##__, m, n) +# define __format__(kind,m,n) __format__ (__##kind##__, m, n) +# define ____printf____ __printf__ +# define ____scanf____ __scanf__ +# define ____strftime____ __strftime__ +# define ____strfmon____ __strfmon__ +#endif + +#if 0 +# if 0 +# define vprintf rpl_vprintf +extern int vprintf (const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 1, 0))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vprintf +# define vprintf(f,a) \ + (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \ + "use gnulib module vprintf-posix for portable " \ + "POSIX compliance"), \ + vprintf (f, a)) +#endif + +#if 1 +# if 0 +# define snprintf rpl_snprintf +# endif +# if 0 || !1 +extern int snprintf (char *str, size_t size, const char *format, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef snprintf +# define snprintf \ + (GL_LINK_WARNING ("snprintf is unportable - " \ + "use gnulib module snprintf for portability"), \ + snprintf) +#endif + +#if 1 +# if 0 +# define vsnprintf rpl_vsnprintf +# endif +# if 0 || !1 +extern int vsnprintf (char *str, size_t size, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 3, 0))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vsnprintf +# define vsnprintf(b,s,f,a) \ + (GL_LINK_WARNING ("vsnprintf is unportable - " \ + "use gnulib module vsnprintf for portability"), \ + vsnprintf (b, s, f, a)) +#endif + +#if 0 +# if 0 +# define sprintf rpl_sprintf +extern int sprintf (char *str, const char *format, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sprintf +# define sprintf \ + (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \ + "use gnulib module sprintf-posix for portable " \ + "POSIX compliance"), \ + sprintf) +#endif + +#if 0 +# if 0 +# define vsprintf rpl_vsprintf +extern int vsprintf (char *str, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vsprintf +# define vsprintf(b,f,a) \ + (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \ + "use gnulib module vsprintf-posix for portable " \ + "POSIX compliance"), \ + vsprintf (b, f, a)) +#endif + +#if 1 +# if 0 +# define asprintf rpl_asprintf +# define vasprintf rpl_vasprintf +# endif +# if 0 || !1 + /* Write formatted output to a string dynamically allocated with malloc(). + If the memory allocation succeeds, store the address of the string in + *RESULT and return the number of resulting bytes, excluding the trailing + NUL. Upon memory allocation error, or some other error, return -1. */ + extern int asprintf (char **result, const char *format, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); + extern int vasprintf (char **result, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))); +# endif +#endif + +#if 0 +# if 0 +# define fopen rpl_fopen +extern FILE * fopen (const char *filename, const char *mode); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fopen +# define fopen(f,m) \ + (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \ + "use gnulib module fopen for portability"), \ + fopen (f, m)) +#endif + +#if 0 +# if 0 +# define freopen rpl_freopen +extern FILE * freopen (const char *filename, const char *mode, FILE *stream); +# endif +#elif defined GNULIB_POSIXCHECK +# undef freopen +# define freopen(f,m,s) \ + (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \ + "use gnulib module freopen for portability"), \ + freopen (f, m, s)) +#endif + +#if 0 +# if 0 +/* Provide fseek, fseeko functions that are aware of a preceding + fflush(), and which detect pipes. */ +# define fseeko rpl_fseeko +extern int fseeko (FILE *fp, off_t offset, int whence); +# define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence) +# endif +#elif defined GNULIB_POSIXCHECK +# undef fseeko +# define fseeko(f,o,w) \ + (GL_LINK_WARNING ("fseeko is unportable - " \ + "use gnulib module fseeko for portability"), \ + fseeko (f, o, w)) +#endif + +#if 0 && 0 +extern int rpl_fseek (FILE *fp, long offset, int whence); +# undef fseek +# if defined GNULIB_POSIXCHECK +# define fseek(f,o,w) \ + (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ + "on 32-bit platforms - " \ + "use fseeko function for handling of large files"), \ + rpl_fseek (f, o, w)) +# else +# define fseek rpl_fseek +# endif +#elif defined GNULIB_POSIXCHECK +# ifndef fseek +# define fseek(f,o,w) \ + (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ + "on 32-bit platforms - " \ + "use fseeko function for handling of large files"), \ + fseek (f, o, w)) +# endif +#endif + +#if 0 +# if 0 +# define ftello rpl_ftello +extern off_t ftello (FILE *fp); +# define ftell(fp) ftello (fp) +# endif +#elif defined GNULIB_POSIXCHECK +# undef ftello +# define ftello(f) \ + (GL_LINK_WARNING ("ftello is unportable - " \ + "use gnulib module ftello for portability"), \ + ftello (f)) +#endif + +#if 0 && 0 +extern long rpl_ftell (FILE *fp); +# undef ftell +# if GNULIB_POSIXCHECK +# define ftell(f) \ + (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ + "on 32-bit platforms - " \ + "use ftello function for handling of large files"), \ + rpl_ftell (f)) +# else +# define ftell rpl_ftell +# endif +#elif defined GNULIB_POSIXCHECK +# ifndef ftell +# define ftell(f) \ + (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ + "on 32-bit platforms - " \ + "use ftello function for handling of large files"), \ + ftell (f)) +# endif +#endif + +#if 0 +# if 0 +# define fflush rpl_fflush + /* Flush all pending data on STREAM according to POSIX rules. Both + output and seekable input streams are supported. + Note! LOSS OF DATA can occur if fflush is applied on an input stream + that is _not_seekable_ or on an update stream that is _not_seekable_ + and in which the most recent operation was input. Seekability can + be tested with lseek(fileno(fp),0,SEEK_CUR). */ + extern int fflush (FILE *gl_stream); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fflush +# define fflush(f) \ + (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \ + "use gnulib module fflush for portable " \ + "POSIX compliance"), \ + fflush (f)) +#endif + +#if 0 +# if !1 +/* Read input, up to (and including) the next occurrence of DELIMITER, from + STREAM, store it in *LINEPTR (and NUL-terminate it). + *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE + bytes of space. It is realloc'd as necessary. + Return the number of bytes read and stored at *LINEPTR (not including the + NUL terminator), or -1 on error or EOF. */ +extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter, + FILE *stream); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getdelim +# define getdelim(l, s, d, f) \ + (GL_LINK_WARNING ("getdelim is unportable - " \ + "use gnulib module getdelim for portability"), \ + getdelim (l, s, d, f)) +#endif + +#if 0 +# if 0 +# undef getline +# define getline rpl_getline +# endif +# if !1 || 0 +/* Read a line, up to (and including) the next newline, from STREAM, store it + in *LINEPTR (and NUL-terminate it). + *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE + bytes of space. It is realloc'd as necessary. + Return the number of bytes read and stored at *LINEPTR (not including the + NUL terminator), or -1 on error or EOF. */ +extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getline +# define getline(l, s, f) \ + (GL_LINK_WARNING ("getline is unportable - " \ + "use gnulib module getline for portability"), \ + getline (l, s, f)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_STDIO_H */ +#endif /* _GL_STDIO_H */ +#endif diff --git a/gl/stdlib.h b/gl/stdlib.h new file mode 100644 index 00000000..86da899f --- /dev/null +++ b/gl/stdlib.h @@ -0,0 +1,237 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* A GNU-like . + + Copyright (C) 1995, 2001-2004, 2006-2007 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#if defined __need_malloc_and_calloc +/* Special invocation convention inside glibc header files. */ + +#include_next + +#else +/* Normal invocation convention. */ + +#ifndef _GL_STDLIB_H + +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_STDLIB_H +#define _GL_STDLIB_H + + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + + +/* Some systems do not define EXIT_*, despite otherwise supporting C89. */ +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere + with proper operation of xargs. */ +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#elif EXIT_FAILURE != 1 +# undef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +#if 1 +# if !1 +# undef malloc +# define malloc rpl_malloc +extern void * malloc (size_t size); +# endif +#elif defined GNULIB_POSIXCHECK +# undef malloc +# define malloc(s) \ + (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \ + "use gnulib module malloc-posix for portability"), \ + malloc (s)) +#endif + + +#if 0 +# if !1 +# undef realloc +# define realloc rpl_realloc +extern void * realloc (void *ptr, size_t size); +# endif +#elif defined GNULIB_POSIXCHECK +# undef realloc +# define realloc(p,s) \ + (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \ + "use gnulib module realloc-posix for portability"), \ + realloc (p, s)) +#endif + + +#if 0 +# if !1 +# undef calloc +# define calloc rpl_calloc +extern void * calloc (size_t nmemb, size_t size); +# endif +#elif defined GNULIB_POSIXCHECK +# undef calloc +# define calloc(n,s) \ + (GL_LINK_WARNING ("calloc is not POSIX compliant everywhere - " \ + "use gnulib module calloc-posix for portability"), \ + calloc (n, s)) +#endif + + +#if 0 +/* Assuming *OPTIONP is a comma separated list of elements of the form + "token" or "token=value", getsubopt parses the first of these elements. + If the first element refers to a "token" that is member of the given + NULL-terminated array of tokens: + - It replaces the comma with a NUL byte, updates *OPTIONP to point past + the first option and the comma, sets *VALUEP to the value of the + element (or NULL if it doesn't contain an "=" sign), + - It returns the index of the "token" in the given array of tokens. + Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. + For more details see the POSIX:2001 specification. + http://www.opengroup.org/susv3xsh/getsubopt.html */ +# if !1 +extern int getsubopt (char **optionp, char *const *tokens, char **valuep); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getsubopt +# define getsubopt(o,t,v) \ + (GL_LINK_WARNING ("getsubopt is unportable - " \ + "use gnulib module getsubopt for portability"), \ + getsubopt (o, t, v)) +#endif + + +#if 0 +# if !1 +/* Create a unique temporary directory from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the directory name unique. + Returns TEMPLATE, or a null pointer if it cannot get a unique name. + The directory is created mode 700. */ +extern char * mkdtemp (char * /*template*/); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkdtemp +# define mkdtemp(t) \ + (GL_LINK_WARNING ("mkdtemp is unportable - " \ + "use gnulib module mkdtemp for portability"), \ + mkdtemp (t)) +#endif + + +#if 0 +# if 0 +/* Create a unique temporary file from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + The file is then created, ensuring it didn't exist before. + The file is created read-write (mask at least 0600 & ~umask), but it may be + world-readable and world-writable (mask 0666 & ~umask), depending on the + implementation. + Returns the open file descriptor if successful, otherwise -1 and errno + set. */ +# define mkstemp rpl_mkstemp +extern int mkstemp (char * /*template*/); +# else +/* On MacOS X 10.3, only declares mkstemp. */ +# include +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkstemp +# define mkstemp(t) \ + (GL_LINK_WARNING ("mkstemp is unportable - " \ + "use gnulib module mkstemp for portability"), \ + mkstemp (t)) +#endif + + +#if 0 +# if 0 +# undef putenv +# define putenv rpl_putenv +extern int putenv (char *string); +# endif +#endif + + +#if 0 +# if !1 +/* Set NAME to VALUE in the environment. + If REPLACE is nonzero, overwrite an existing value. */ +extern int setenv (const char *name, const char *value, int replace); +# endif +#endif + + +#if 0 +# if 1 +# if 0 +/* On some systems, unsetenv() returns void. + This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4. */ +# define unsetenv(name) ((unsetenv)(name), 0) +# endif +# else +/* Remove the variable NAME from the environment. */ +extern int unsetenv (const char *name); +# endif +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_STDLIB_H */ +#endif /* _GL_STDLIB_H */ +#endif diff --git a/gl/string.h b/gl/string.h new file mode 100644 index 00000000..e5bcef55 --- /dev/null +++ b/gl/string.h @@ -0,0 +1,598 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* A GNU-like . + + Copyright (C) 1995-1996, 2001-2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _GL_STRING_H + +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_STRING_H +#define _GL_STRING_H + + +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +# define __attribute__(Spec) /* empty */ +# endif +/* The attribute __pure__ was added in gcc 2.96. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) +# define __pure__ /* empty */ +# endif +#endif + + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Return the first occurrence of NEEDLE in HAYSTACK. */ +#if 0 +# if 0 +# define memmem rpl_memmem +# endif +# if ! 1 || 0 +extern void *memmem (void const *__haystack, size_t __haystack_len, + void const *__needle, size_t __needle_len) + __attribute__ ((__pure__)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef memmem +# define memmem(a,al,b,bl) \ + (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \ + "use gnulib module memmem-simple for portability, " \ + "and module memmem for speed" ), \ + memmem (a, al, b, bl)) +#endif + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +#if 0 +# if ! 1 +extern void *mempcpy (void *restrict __dest, void const *restrict __src, + size_t __n); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mempcpy +# define mempcpy(a,b,n) \ + (GL_LINK_WARNING ("mempcpy is unportable - " \ + "use gnulib module mempcpy for portability"), \ + mempcpy (a, b, n)) +#endif + +/* Search backwards through a block for a byte (specified as an int). */ +#if 0 +# if ! 1 +extern void *memrchr (void const *, int, size_t) + __attribute__ ((__pure__)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef memrchr +# define memrchr(a,b,c) \ + (GL_LINK_WARNING ("memrchr is unportable - " \ + "use gnulib module memrchr for portability"), \ + memrchr (a, b, c)) +#endif + +/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ +#if 0 +# if ! 1 +extern char *stpcpy (char *restrict __dst, char const *restrict __src); +# endif +#elif defined GNULIB_POSIXCHECK +# undef stpcpy +# define stpcpy(a,b) \ + (GL_LINK_WARNING ("stpcpy is unportable - " \ + "use gnulib module stpcpy for portability"), \ + stpcpy (a, b)) +#endif + +/* Copy no more than N bytes of SRC to DST, returning a pointer past the + last non-NUL byte written into DST. */ +#if 0 +# if ! 1 +# define stpncpy gnu_stpncpy +extern char *stpncpy (char *restrict __dst, char const *restrict __src, + size_t __n); +# endif +#elif defined GNULIB_POSIXCHECK +# undef stpncpy +# define stpncpy(a,b,n) \ + (GL_LINK_WARNING ("stpncpy is unportable - " \ + "use gnulib module stpncpy for portability"), \ + stpncpy (a, b, n)) +#endif + +#if defined GNULIB_POSIXCHECK +/* strchr() does not work with multibyte strings if the locale encoding is + GB18030 and the character to be searched is a digit. */ +# undef strchr +# define strchr(s,c) \ + (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \ + "in some multibyte locales - " \ + "use mbschr if you care about internationalization"), \ + strchr (s, c)) +#endif + +/* Find the first occurrence of C in S or the final NUL byte. */ +#if 0 +# if ! 1 +extern char *strchrnul (char const *__s, int __c_in) + __attribute__ ((__pure__)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strchrnul +# define strchrnul(a,b) \ + (GL_LINK_WARNING ("strchrnul is unportable - " \ + "use gnulib module strchrnul for portability"), \ + strchrnul (a, b)) +#endif + +/* Duplicate S, returning an identical malloc'd string. */ +#if 1 +# if ! 1 && ! defined strdup +extern char *strdup (char const *__s); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strdup +# define strdup(a) \ + (GL_LINK_WARNING ("strdup is unportable - " \ + "use gnulib module strdup for portability"), \ + strdup (a)) +#endif + +/* Return a newly allocated copy of at most N bytes of STRING. */ +#if 1 +# if ! 1 +# undef strndup +# define strndup rpl_strndup +# endif +# if ! 1 || ! 1 +extern char *strndup (char const *__string, size_t __n); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strndup +# define strndup(a,n) \ + (GL_LINK_WARNING ("strndup is unportable - " \ + "use gnulib module strndup for portability"), \ + strndup (a, n)) +#endif + +/* Find the length (number of bytes) of STRING, but scan at most + MAXLEN bytes. If no '\0' terminator is found in that many bytes, + return MAXLEN. */ +#if 1 +# if ! 1 +extern size_t strnlen (char const *__string, size_t __maxlen) + __attribute__ ((__pure__)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strnlen +# define strnlen(a,n) \ + (GL_LINK_WARNING ("strnlen is unportable - " \ + "use gnulib module strnlen for portability"), \ + strnlen (a, n)) +#endif + +#if defined GNULIB_POSIXCHECK +/* strcspn() assumes the second argument is a list of single-byte characters. + Even in this simple case, it does not work with multibyte strings if the + locale encoding is GB18030 and one of the characters to be searched is a + digit. */ +# undef strcspn +# define strcspn(s,a) \ + (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbscspn if you care about internationalization"), \ + strcspn (s, a)) +#endif + +/* Find the first occurrence in S of any character in ACCEPT. */ +#if 0 +# if ! 1 +extern char *strpbrk (char const *__s, char const *__accept) + __attribute__ ((__pure__)); +# endif +# if defined GNULIB_POSIXCHECK +/* strpbrk() assumes the second argument is a list of single-byte characters. + Even in this simple case, it does not work with multibyte strings if the + locale encoding is GB18030 and one of the characters to be searched is a + digit. */ +# undef strpbrk +# define strpbrk(s,a) \ + (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbspbrk if you care about internationalization"), \ + strpbrk (s, a)) +# endif +#elif defined GNULIB_POSIXCHECK +# undef strpbrk +# define strpbrk(s,a) \ + (GL_LINK_WARNING ("strpbrk is unportable - " \ + "use gnulib module strpbrk for portability"), \ + strpbrk (s, a)) +#endif + +#if defined GNULIB_POSIXCHECK +/* strspn() assumes the second argument is a list of single-byte characters. + Even in this simple case, it cannot work with multibyte strings. */ +# undef strspn +# define strspn(s,a) \ + (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbsspn if you care about internationalization"), \ + strspn (s, a)) +#endif + +#if defined GNULIB_POSIXCHECK +/* strrchr() does not work with multibyte strings if the locale encoding is + GB18030 and the character to be searched is a digit. */ +# undef strrchr +# define strrchr(s,c) \ + (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \ + "in some multibyte locales - " \ + "use mbsrchr if you care about internationalization"), \ + strrchr (s, c)) +#endif + +/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. + If one is found, overwrite it with a NUL, and advance *STRINGP + to point to the next char after it. Otherwise, set *STRINGP to NULL. + If *STRINGP was already NULL, nothing happens. + Return the old value of *STRINGP. + + This is a variant of strtok() that is multithread-safe and supports + empty fields. + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strtok_r(). */ +#if 0 +# if ! 1 +extern char *strsep (char **restrict __stringp, char const *restrict __delim); +# endif +# if defined GNULIB_POSIXCHECK +# undef strsep +# define strsep(s,d) \ + (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbssep if you care about internationalization"), \ + strsep (s, d)) +# endif +#elif defined GNULIB_POSIXCHECK +# undef strsep +# define strsep(s,d) \ + (GL_LINK_WARNING ("strsep is unportable - " \ + "use gnulib module strsep for portability"), \ + strsep (s, d)) +#endif + +#if 0 +# if 0 +# define strstr rpl_strstr +char *strstr (const char *haystack, const char *needle) + __attribute__ ((__pure__)); +# endif +#elif defined GNULIB_POSIXCHECK +/* strstr() does not work with multibyte strings if the locale encoding is + different from UTF-8: + POSIX says that it operates on "strings", and "string" in POSIX is defined + as a sequence of bytes, not of characters. */ +# undef strstr +# define strstr(a,b) \ + (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \ + "work correctly on character strings in most " \ + "multibyte locales - " \ + "use mbsstr if you care about internationalization, " \ + "or use strstr if you care about speed"), \ + strstr (a, b)) +#endif + +/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive + comparison. */ +#if 0 +# if 0 +# define strcasestr rpl_strcasestr +# endif +# if ! 1 || 0 +extern char *strcasestr (const char *haystack, const char *needle) + __attribute__ ((__pure__)); +# endif +#elif defined GNULIB_POSIXCHECK +/* strcasestr() does not work with multibyte strings: + It is a glibc extension, and glibc implements it only for unibyte + locales. */ +# undef strcasestr +# define strcasestr(a,b) \ + (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \ + "in multibyte locales - " \ + "use mbscasestr if you care about " \ + "internationalization, or use c-strcasestr if you want " \ + "a locale independent function"), \ + strcasestr (a, b)) +#endif + +/* Parse S into tokens separated by characters in DELIM. + If S is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = strtok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" + + This is a variant of strtok() that is multithread-safe. + + For the POSIX documentation for this function, see: + http://www.opengroup.org/susv3xsh/strtok.html + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strsep(). */ +#if 0 +# if ! 1 +extern char *strtok_r (char *restrict s, char const *restrict delim, + char **restrict save_ptr); +# endif +# if defined GNULIB_POSIXCHECK +# undef strtok_r +# define strtok_r(s,d,p) \ + (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbstok_r if you care about internationalization"), \ + strtok_r (s, d, p)) +# endif +#elif defined GNULIB_POSIXCHECK +# undef strtok_r +# define strtok_r(s,d,p) \ + (GL_LINK_WARNING ("strtok_r is unportable - " \ + "use gnulib module strtok_r for portability"), \ + strtok_r (s, d, p)) +#endif + + +/* The following functions are not specified by POSIX. They are gnulib + extensions. */ + +#if 0 +/* Return the number of multibyte characters in the character string STRING. + This considers multibyte characters, unlike strlen, which counts bytes. */ +extern size_t mbslen (const char *string); +#endif + +#if 0 +/* Return the number of multibyte characters in the character string starting + at STRING and ending at STRING + LEN. */ +extern size_t mbsnlen (const char *string, size_t len); +#endif + +#if 0 +/* Locate the first single-byte character C in the character string STRING, + and return a pointer to it. Return NULL if C is not found in STRING. + Unlike strchr(), this function works correctly in multibyte locales with + encodings such as GB18030. */ +# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ +extern char * mbschr (const char *string, int c); +#endif + +#if 0 +/* Locate the last single-byte character C in the character string STRING, + and return a pointer to it. Return NULL if C is not found in STRING. + Unlike strrchr(), this function works correctly in multibyte locales with + encodings such as GB18030. */ +# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ +extern char * mbsrchr (const char *string, int c); +#endif + +#if 0 +/* Find the first occurrence of the character string NEEDLE in the character + string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. + Unlike strstr(), this function works correctly in multibyte locales with + encodings different from UTF-8. */ +extern char * mbsstr (const char *haystack, const char *needle); +#endif + +#if 0 +/* Compare the character strings S1 and S2, ignoring case, returning less than, + equal to or greater than zero if S1 is lexicographically less than, equal to + or greater than S2. + Note: This function may, in multibyte locales, return 0 for strings of + different lengths! + Unlike strcasecmp(), this function works correctly in multibyte locales. */ +extern int mbscasecmp (const char *s1, const char *s2); +#endif + +#if 0 +/* Compare the initial segment of the character string S1 consisting of at most + N characters with the initial segment of the character string S2 consisting + of at most N characters, ignoring case, returning less than, equal to or + greater than zero if the initial segment of S1 is lexicographically less + than, equal to or greater than the initial segment of S2. + Note: This function may, in multibyte locales, return 0 for initial segments + of different lengths! + Unlike strncasecmp(), this function works correctly in multibyte locales. + But beware that N is not a byte count but a character count! */ +extern int mbsncasecmp (const char *s1, const char *s2, size_t n); +#endif + +#if 0 +/* Compare the initial segment of the character string STRING consisting of + at most mbslen (PREFIX) characters with the character string PREFIX, + ignoring case, returning less than, equal to or greater than zero if this + initial segment is lexicographically less than, equal to or greater than + PREFIX. + Note: This function may, in multibyte locales, return 0 if STRING is of + smaller length than PREFIX! + Unlike strncasecmp(), this function works correctly in multibyte + locales. */ +extern char * mbspcasecmp (const char *string, const char *prefix); +#endif + +#if 0 +/* Find the first occurrence of the character string NEEDLE in the character + string HAYSTACK, using case-insensitive comparison. + Note: This function may, in multibyte locales, return success even if + strlen (haystack) < strlen (needle) ! + Unlike strcasestr(), this function works correctly in multibyte locales. */ +extern char * mbscasestr (const char *haystack, const char *needle); +#endif + +#if 0 +/* Find the first occurrence in the character string STRING of any character + in the character string ACCEPT. Return the number of bytes from the + beginning of the string to this occurrence, or to the end of the string + if none exists. + Unlike strcspn(), this function works correctly in multibyte locales. */ +extern size_t mbscspn (const char *string, const char *accept); +#endif + +#if 0 +/* Find the first occurrence in the character string STRING of any character + in the character string ACCEPT. Return the pointer to it, or NULL if none + exists. + Unlike strpbrk(), this function works correctly in multibyte locales. */ +# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ +extern char * mbspbrk (const char *string, const char *accept); +#endif + +#if 0 +/* Find the first occurrence in the character string STRING of any character + not in the character string REJECT. Return the number of bytes from the + beginning of the string to this occurrence, or to the end of the string + if none exists. + Unlike strspn(), this function works correctly in multibyte locales. */ +extern size_t mbsspn (const char *string, const char *reject); +#endif + +#if 0 +/* Search the next delimiter (multibyte character listed in the character + string DELIM) starting at the character string *STRINGP. + If one is found, overwrite it with a NUL, and advance *STRINGP to point + to the next multibyte character after it. Otherwise, set *STRINGP to NULL. + If *STRINGP was already NULL, nothing happens. + Return the old value of *STRINGP. + + This is a variant of mbstok_r() that supports empty fields. + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + + See also mbstok_r(). */ +extern char * mbssep (char **stringp, const char *delim); +#endif + +#if 0 +/* Parse the character string STRING into tokens separated by characters in + the character string DELIM. + If STRING is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = mbstok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + + See also mbssep(). */ +extern char * mbstok_r (char *string, const char *delim, char **save_ptr); +#endif + +/* Map any int, typically from errno, into an error message. */ +#if 1 +# if 0 +# undef strerror +# define strerror rpl_strerror +extern char *strerror (int); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strerror +# define strerror(e) \ + (GL_LINK_WARNING ("strerror is unportable - " \ + "use gnulib module strerror to guarantee non-NULL result"), \ + strerror (e)) +#endif + +#if 0 +# if 0 +# define strsignal rpl_strsignal +# endif +# if ! 1 || 0 +extern char *strsignal (int __sig); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strsignal +# define strsignal(a) \ + (GL_LINK_WARNING ("strsignal is unportable - " \ + "use gnulib module strsignal for portability"), \ + strsignal (a)) +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_STRING_H */ +#endif /* _GL_STRING_H */ diff --git a/gl/unistd.h b/gl/unistd.h new file mode 100644 index 00000000..e72a5d9a --- /dev/null +++ b/gl/unistd.h @@ -0,0 +1,321 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* Substitute for and wrapper around . + Copyright (C) 2004-2007 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _GL_UNISTD_H + +/* The include_next requires a split double-inclusion guard. */ +#if 1 +# include_next +#endif + +#ifndef _GL_UNISTD_H +#define _GL_UNISTD_H + +/* mingw doesn't define the SEEK_* macros in . */ +#if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) +# include +#endif + +/* mingw fails to declare _exit in . */ +#include + +/* The definition of GL_LINK_WARNING is copied here. */ + + +/* Declare overridden functions. */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#if 0 +# if 0 +# ifndef REPLACE_CHOWN +# define REPLACE_CHOWN 1 +# endif +# if REPLACE_CHOWN +/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE + to GID (if GID is not -1). Follow symbolic links. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +# define chown rpl_chown +extern int chown (const char *file, uid_t uid, gid_t gid); +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# undef chown +# define chown(f,u,g) \ + (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \ + "doesn't treat a uid or gid of -1 on some systems - " \ + "use gnulib module chown for portability"), \ + chown (f, u, g)) +#endif + + +#if 0 +# if !1 +/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if + NEWFD = OLDFD, otherwise close NEWFD first if it is open. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +extern int dup2 (int oldfd, int newfd); +# endif +#elif defined GNULIB_POSIXCHECK +# undef dup2 +# define dup2(o,n) \ + (GL_LINK_WARNING ("dup2 is unportable - " \ + "use gnulib module dup2 for portability"), \ + dup2 (o, n)) +#endif + + +#if 0 +# if 0 + +/* Change the process' current working directory to the directory on which + the given file descriptor is open. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +extern int fchdir (int /*fd*/); + +# define close rpl_close +extern int close (int); +# define dup rpl_dup +extern int dup (int); +# define dup2 rpl_dup2 +extern int dup2 (int, int); + +# endif +#elif defined GNULIB_POSIXCHECK +# undef fchdir +# define fchdir(f) \ + (GL_LINK_WARNING ("fchdir is unportable - " \ + "use gnulib module fchdir for portability"), \ + fchdir (f)) +#endif + + +#if 0 +# if !1 +/* Change the size of the file to which FD is opened to become equal to LENGTH. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +extern int ftruncate (int fd, off_t length); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ftruncate +# define ftruncate(f,l) \ + (GL_LINK_WARNING ("ftruncate is unportable - " \ + "use gnulib module ftruncate for portability"), \ + ftruncate (f, l)) +#endif + + +#if 0 +/* Include the headers that might declare getcwd so that they will not + cause confusion if included after this file. */ +# include +# if 0 +/* Get the name of the current working directory, and put it in SIZE bytes + of BUF. + Return BUF if successful, or NULL if the directory couldn't be determined + or SIZE was too small. + See the POSIX:2001 specification + . + Additionally, the gnulib module 'getcwd' guarantees the following GNU + extension: If BUF is NULL, an array is allocated with 'malloc'; the array + is SIZE bytes long, unless SIZE == 0, in which case it is as big as + necessary. */ +# define getcwd rpl_getcwd +extern char * getcwd (char *buf, size_t size); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getcwd +# define getcwd(b,s) \ + (GL_LINK_WARNING ("getcwd is unportable - " \ + "use gnulib module getcwd for portability"), \ + getcwd (b, s)) +#endif + + +#if 0 +/* Copies the user's login name to NAME. + The array pointed to by NAME has room for SIZE bytes. + + Returns 0 if successful. Upon error, an error number is returned, or -1 in + the case that the login name cannot be found but no specific error is + provided (this case is hopefully rare but is left open by the POSIX spec). + + See . + */ +# if !1 +# include +extern int getlogin_r (char *name, size_t size); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getlogin_r +# define getlogin_r(n,s) \ + (GL_LINK_WARNING ("getlogin_r is unportable - " \ + "use gnulib module getlogin_r for portability"), \ + getlogin_r (n, s)) +#endif + + +#if 0 +# if 0 +# define getpagesize rpl_getpagesize +extern int getpagesize (void); +# elif !1 +/* This is for POSIX systems. */ +# if !defined getpagesize && defined _SC_PAGESIZE +# if ! (defined __VMS && __VMS_VER < 70000000) +# define getpagesize() sysconf (_SC_PAGESIZE) +# endif +# endif +/* This is for older VMS. */ +# if !defined getpagesize && defined __VMS +# ifdef __ALPHA +# define getpagesize() 8192 +# else +# define getpagesize() 512 +# endif +# endif +/* This is for BeOS. */ +# if !defined getpagesize && 0 +# include +# if defined B_PAGE_SIZE +# define getpagesize() B_PAGE_SIZE +# endif +# endif +/* This is for AmigaOS4.0. */ +# if !defined getpagesize && defined __amigaos4__ +# define getpagesize() 2048 +# endif +/* This is for older Unix systems. */ +# if !defined getpagesize && 0 +# include +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else +# ifdef NBPG +# ifndef CLSIZE +# define CLSIZE 1 +# endif +# define getpagesize() (NBPG * CLSIZE) +# else +# ifdef NBPC +# define getpagesize() NBPC +# endif +# endif +# endif +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# undef getpagesize +# define getpagesize() \ + (GL_LINK_WARNING ("getpagesize is unportable - " \ + "use gnulib module getpagesize for portability"), \ + getpagesize ()) +#endif + + +#if 0 +# if 0 +/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE + to GID (if GID is not -1). Do not follow symbolic links. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +# define lchown rpl_lchown +extern int lchown (char const *file, uid_t owner, gid_t group); +# endif +#elif defined GNULIB_POSIXCHECK +# undef lchown +# define lchown(f,u,g) \ + (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \ + "systems - use gnulib module lchown for portability"), \ + lchown (f, u, g)) +#endif + + +#if 0 +# if 0 +/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. + Return the new offset if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +# define lseek rpl_lseek + extern off_t lseek (int fd, off_t offset, int whence); +# endif +#elif defined GNULIB_POSIXCHECK +# undef lseek +# define lseek(f,o,w) \ + (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \ + "systems - use gnulib module lseek for portability"), \ + lseek (f, o, w)) +#endif + + +#if 0 +/* Read the contents of the symbolic link FILE and place the first BUFSIZE + bytes of it into BUF. Return the number of bytes placed into BUF if + successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +# if !1 +# include +extern int readlink (const char *file, char *buf, size_t bufsize); +# endif +#elif defined GNULIB_POSIXCHECK +# undef readlink +# define readlink(f,b,s) \ + (GL_LINK_WARNING ("readlink is unportable - " \ + "use gnulib module readlink for portability"), \ + readlink (f, b, s)) +#endif + + +#if 0 +/* Pause the execution of the current thread for N seconds. + Returns the number of seconds left to sleep. + See the POSIX:2001 specification + . */ +# if !1 +extern unsigned int sleep (unsigned int n); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sleep +# define sleep(n) \ + (GL_LINK_WARNING ("sleep is unportable - " \ + "use gnulib module sleep for portability"), \ + sleep (n)) +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _GL_UNISTD_H */ +#endif /* _GL_UNISTD_H */ diff --git a/lib/Makefile.am b/lib/Makefile.am index 36ff245c..5d65bed6 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -5,8 +5,8 @@ SUBDIRS = tests noinst_LIBRARIES = libnagiosplug.a -libnagiosplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c base64.c -EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h base64.h +libnagiosplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c +EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h INCLUDES = -I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins diff --git a/lib/base64.c b/lib/base64.c deleted file mode 100644 index 1f1fcb8c..00000000 --- a/lib/base64.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -* Function to encode in Base64 -* -* Written by Lauri Alanko -* -*****************************************************************************/ - -#include "common.h" -#include "base64.h" - -char * -base64 (const char *bin, size_t len) -{ - - char *buf = (char *) malloc ((len + 2) / 3 * 4 + 1); - size_t i = 0, j = 0; - - char BASE64_END = '='; - char base64_table[64]; - strncpy (base64_table, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 64); - - while (j < len - 2) { - buf[i++] = base64_table[bin[j] >> 2]; - buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)]; - buf[i++] = base64_table[((bin[j + 1] & 15) << 2) | (bin[j + 2] >> 6)]; - buf[i++] = base64_table[bin[j + 2] & 63]; - j += 3; - } - - switch (len - j) { - case 1: - buf[i++] = base64_table[bin[j] >> 2]; - buf[i++] = base64_table[(bin[j] & 3) << 4]; - buf[i++] = BASE64_END; - buf[i++] = BASE64_END; - break; - case 2: - buf[i++] = base64_table[bin[j] >> 2]; - buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)]; - buf[i++] = base64_table[(bin[j + 1] & 15) << 2]; - buf[i++] = BASE64_END; - break; - case 0: - break; - } - - buf[i] = '\0'; - return buf; -} - diff --git a/lib/base64.h b/lib/base64.h deleted file mode 100644 index 1e0a0b04..00000000 --- a/lib/base64.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Header file for base64.c */ - -char *base64 (const char *bin, size_t len); - diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am index 0ddc8abf..bd25ccfe 100644 --- a/lib/tests/Makefile.am +++ b/lib/tests/Makefile.am @@ -36,7 +36,7 @@ test_cmd_LDADD = ../utils_cmd.o ../utils_base.o test_base64_SOURCES = test_base64.c test_base64_CFLAGS = -g -I.. test_base64_LDFLAGS = -L/usr/local/lib -ltap -test_base64_LDADD = ../base64.o +test_base64_LDADD = $(top_srcdir)/gl/base64.o test: ${noinst_PROGRAMS} perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS) diff --git a/lib/tests/test_base64.c b/lib/tests/test_base64.c index e3ff3e35..650cfa1a 100644 --- a/lib/tests/test_base64.c +++ b/lib/tests/test_base64.c @@ -18,13 +18,12 @@ *****************************************************************************/ #include "common.h" -#include "base64.h" +#include "gl/base64.h" #include "tap.h" int main (int argc, char **argv) { -#if 0 /* The current base64 function doesn't work on 8bit data */ char random[1024] = { 0x8b,0xb0,0xc4,0xe2,0xfc,0x22,0x9f,0x0d,0x85,0xe7,0x2c,0xaa,0x39,0xa1,0x46,0x88, 0x50,0xe6,0x34,0x37,0x0b,0x45,0x4b,0xb8,0xb2,0x86,0x7a,0x3e,0x7f,0x0c,0x40,0x18, @@ -180,8 +179,9 @@ main (int argc, char **argv) 0x46,0x62,0x5a,0x61,0x35,0x52,0x6e,0x50,0x59,0x43,0x4f,0x36,0x4f,0x70,0x4d,0x6c, 0x41,0x6e,0x6a,0x4d,0x56,0x41,0x3d,0x3d }; -#endif +#if 0 + /* The old base64 function didn't work on 8bit data, below is 7bit */ char random[1024] = { 0x0b,0x30,0x44,0x62,0x7c,0x22,0x1f,0x0d,0x05,0x67,0x2c,0x2a,0x39,0x21,0x46,0x08, 0x50,0x66,0x34,0x37,0x0b,0x45,0x4b,0x38,0x32,0x06,0x7a,0x3e,0x7f,0x0c,0x40,0x18, @@ -336,11 +336,13 @@ main (int argc, char **argv) 0x46,0x54,0x5a,0x61,0x5a,0x52,0x6c,0x50,0x59,0x43,0x4d,0x36,0x4f,0x68,0x4d,0x6c, 0x41,0x6e,0x68,0x4d,0x56,0x41,0x3d,0x3d,0x00 }; +#endif + char *b64_test; plan_tests(1); - b64_test = base64 (random, 1024); + base64_encode_alloc (random, 1024, &b64_test); ok(strcmp(b64_known, b64_test) == 0, "Test matching a base64 encoded 1024 bytes random string"); diff --git a/plugins/check_http.c b/plugins/check_http.c index 02754021..151eacac 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -764,7 +764,7 @@ check_http (void) /* optionally send the authentication info */ if (strlen(user_auth)) { - auth = base64 (user_auth, strlen (user_auth)); + base64_encode_alloc (user_auth, strlen (user_auth), &auth); asprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth); } diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index d3e4f42e..3310bceb 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -366,7 +366,8 @@ main (int argc, char **argv) } /* encode authuser with base64 */ - abuf = base64 (authuser, strlen(authuser)); + base64_encode_alloc (authuser, strlen(authuser), &abuf); + /* FIXME: abuf shouldn't have enough space to strcat a '\r\n' into it. */ strcat (abuf, "\r\n"); my_send(abuf, strlen(abuf)); if (verbose) @@ -386,7 +387,8 @@ main (int argc, char **argv) break; } /* encode authpass with base64 */ - abuf = base64 (authpass, strlen(authpass)); + base64_encode_alloc (authpass, strlen(authpass), &abuf); + /* FIXME: abuf shouldn't have enough space to strcat a '\r\n' into it. */ strcat (abuf, "\r\n"); my_send(abuf, strlen(abuf)); if (verbose) { -- cgit v1.2.3-74-g34f1